PHP入門–array_splice()とforeach()で配列を操作する

1.array_splice()
<?php
$cft_array=array(
“chang"=>"shinagawa",
“A"=>"oosa",
“oosa"=>"kktest"
);
$new_arr=array_splice($cft_array,1,3);
var_dump($new_arr);
?>

実行結果:
array(2) { [“A"]=> string(2) “oosa" [“oosa"]=> string(2) “kktest" }

2.foreach()
<?php
$cft_array=array(
“chang"=>"shinagawa",
“A"=>"oosa",
“oosa"=>"kktest"
);
foreach($my_array as $key=>$value)
{
echo $key."=>".$value."<br/>";
}
?>

実行結果:
chang=>shinagawa
A=>oosa
oosa=>kktest

PHP

Posted by arkgame