这样就算会了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>";
    }
?>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。