PHP完全自学手册(珍藏版) 中文pdf扫描版下载
$arr = array(5 => 1, 12 => 2);
$arr[] = 56; // This is the same as $arr[13] = 56;
// at this point of the script
$arr["x"] = 42; // This adds a new element to
// the array with key "x"
unset($arr[5]); // This removes the element from the array
unset($arr); // This deletes the whole array
?>
<?php
class foo
{
function do_foo()
{
echo "Doing foo.";
}
}
$bar = new foo;
$bar->do_foo();
?>
<?php
$arr1=array(100,200,300,400);
$arr2=array("num"=>100,"name"=>"Liuxy","score"=>98);
print_r($arr1);
echo "<br>";
print_r($arr2);
?>
以上代码的输出结果如下:
Array ( [0] => 100 [1] => 200 [2] => 300 [3] => 400 )
Array ( [num] => 100 [name] => Liuxy [score] => 98 )
转载请注明:谷谷点程序 » php数组应用和对象