現在連想配列を使ってプログラムを組んでいるのですが、
多次元連想配列になると、どのように値を追加していいかわからなくなります。
そこで質問があります、
以下の連想配列$arrayに連想配列$array2の「array('apple'=>'りんご', 'peach'=>'もも'),」部分を追加するにはどうしたらいいでしょうか?
PHP
1<!DOCTYPE HTML> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 5<title></title> 6</head> 7<body> 8<?php 9 $array = array 10 ('fruits'=>array 11 ( 12 array('apple'=>'りんご', 'peach'=>'もも'), 13 array('apple'=>'りんご', 'peach'=>'もも'), 14 array('apple'=>'りんご', 'peach'=>'もも') 15 ) 16 ); 17 18 echo "<pre>"; 19 print_r($array); 20 echo "</pre>"; 21 22 $array2 = array 23 ('fruits'=>array 24 ( 25 array('apple'=>'りんご', 'peach'=>'もも'), 26 array('apple'=>'りんご', 'peach'=>'もも'), 27 array('apple'=>'りんご', 'peach'=>'もも') 28 ) 29 ); 30 31 // $arrayに$array2の「array('apple'=>'りんご', 'peach'=>'もも'),」部分を追加したい 32?> 33</body> 34</html> 35
完成図
Array ( [fruits] => Array ( [0] => Array ( [apple] => りんご [peach] => もも ) [1] => Array ( [apple] => りんご [peach] => もも ) [2] => Array ( [apple] => りんご [peach] => もも ) [3] => Array ( [apple] => りんご [peach] => もも ) [4] => Array ( [apple] => りんご [peach] => もも ) [5] => Array ( [apple] => りんご [peach] => もも ) ) )
もしわかる方がいればお願い致します。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/11 16:21