$fruits = array("apple", "banana", "cherry");
或者
$fruits = ["apple", "banana", "cherry"];
$person = array("name" => "John", "age" => 30, "gender" => "male");
或者
$person = ["name" => "John", "age" => 30, "gender" => "male"];
echo $fruits[0]; // 输出 "蛇皮资源社"
echo $person["name"]; // 输出 "John"
$fruits[] = "orange";
$fruits[1] = "grape";
unset($fruits[2]);
$length = count($fruits);
for ($i = 0; $i < count($fruits); $i++) { echo $fruits[$i]." "; }
foreach ($fruits as $fruit) { echo $fruit." "; }
或者
foreach ($person as $key => $value) { echo $key." : ".$value."<br>"; }
© 版权声明
THE END
暂无评论内容