[PHP]配列演算

配列演算


PHP

$a = array('a' => 'b','c'=>'d','e'=>'f' );
$b = array('g' => 'h','i'=>'j','k'=>'l','a'=>'あ' );
$c = $a+$b;
foreach ($c as $key => $value) {
	echo $key.' : '.$value.'<br/>';
}

出力結果



PHP

$a = array('a' => 'b','c'=>'d','e'=>'f' );
$b = array('g' => 'h','i'=>'j','k'=>'l','a'=>'あ' );
$c=array_merge($a,$b);
foreach ($c as $key => $value) {
	echo $key.' : '.$value.'<br/>';
}

出力結果



PHP

$a = array('a','b','c');
$b = array('d','e','f','g');
$c = $a+$b;
foreach ($c as $key => $value) {
	echo $key.' : '.$value.'<br/>';
}

出力結果



PHP

$a = array('a','b','c');
$b = array('d','e','f','g');
$c=array_merge($a,$b);
foreach ($c as $key => $value) {
	echo $key.' : '.$value.'<br/>';
}

出力結果



下記はエラーになる。

$c = $a-$b;
$c = $a*$b;
$c = $a/$b;