首页 > 代码库 > 这样就算会了PHP么?-4

这样就算会了PHP么?-4

数组初步

<?php    $ereg = ‘tm‘;    $str = ‘hello,tm,Tm,tM,TM.‘;    $rep_str = eregi_replace($ereg, ‘TM‘, $str);    echo $rep_str;    echo ‘<br>‘;    $ereg2 = ‘is‘;    $str2 = ‘This is a register book.‘;    $arr_str2 = split($ereg2, $str2);    var_dump($arr_str2);    echo ‘<br>‘;    $array = array("asp", "php", "jsp");    print_r($array);    echo ‘<br>‘;    echo $array[0];    echo ‘<br>‘;    $array2 = array("1"=>"编", "2"=>"程", "3"=>"词", "4"=>"典");    print_r($array2);    echo ‘<br>‘;    echo $array2[1];    $array2[5] = "好";    echo ‘<br>‘;    print_r($array2);    echo ‘<br>‘;    $newarray = array("first"=>1,"second"=>2, "third" => 3);    echo $newarray["second"];    $newarray["third"] = 8;    echo $newarray["third"];    echo ‘<br>‘;    foreach ($array2 as $array2s) {        echo $array2s.‘<br><br>‘;    }    while (list($num, $value) = each($newarray)) {        echo "$num = $value<br>";    }?>

这样就算会了PHP么?-4