php 數(shù)組 array php函數(shù)

字號(hào):


    重新學(xué)習(xí)一下php的相關(guān)函數(shù)定義等內(nèi)容,學(xué)習(xí)全部,加深印象,字母從a-z
    首先學(xué)習(xí)php數(shù)組,array,數(shù)組定義,數(shù)組的初始化
    看例子學(xué)習(xí)數(shù)組
    例子1:有索引的數(shù)組
    <?php
    $forasp = array(size=>'forasp',domain=>'cn',name=>'');
    //或者
    print_r($forasp);
    ?>
    輸出結(jié)果
    array
    (
    [size] => forasp
    [domain] => cn
    [name] =>
    )
    例子2 無索引數(shù)組
    <?php
    $forasp = array(cn,2,3,4);
    print_r($forasp);
    ?>
    輸出結(jié)果:
    array
    (
    [0] => cn
    [1] => 2
    [2] => 3
    [3] => 4
    )
    例子3 二級(jí)數(shù)組以及多級(jí)數(shù)組
    <?php
    $forasp = array(class1=>一級(jí)數(shù)組內(nèi)容,class2=>array(content=>二級(jí)數(shù)組內(nèi)容));
    print_r($forasp);
    ?>
    輸出結(jié)果
    array
    (
    [class1] => 一級(jí)數(shù)組內(nèi)容
    [class2] => array
    (
    [content] => 二級(jí)數(shù)組內(nèi)容
    )
    )
    例子4 動(dòng)態(tài)添加數(shù)組內(nèi)容
    <?php
    $forasp =array();
    $forasp[]=anypoetry.com;//有索引內(nèi)容
    $forasp[] = 網(wǎng)站制作學(xué)習(xí)網(wǎng);//無索引內(nèi)容
    print_r($forasp);
    ?>
    輸出結(jié)果
    array
    (
    [0] => anypoetry.com
    [1] => 網(wǎng)站制作學(xué)習(xí)網(wǎng)
    )
    這就是php數(shù)組array的基本定義,下次繼續(xù)說php的相關(guān)的操作函數(shù)