[TYPO3-dev] new array operations :-)

Steffen Kamper info at sk-typo3.de
Mon Mar 15 17:28:26 CET 2010


Hi,

never saw that, so i want to share

$a = array(
	'a' => "Apfel",
	'b' => "Banane",
);

$b = array(
	'a' => 'Anker',
	's' => "Sonne",
	'm' => "Meer",
);
echo '<pre>';
print_r($a + $b);
print_r(array_merge($a, $b));
echo '</pre>';

result:
Array
(
     [a] => Apfel
     [b] => Banane
     [s] => Sonne
     [m] => Meer
)
Array
(
     [a] => Anker
     [b] => Banane
     [s] => Sonne
     [m] => Meer
)


so $a + $b is same as array_merge, but first array wins, with 
array_merge second wins.

What a pity that $a - $b is not supported, that would be consequent.

vg Steffen





More information about the TYPO3-dev mailing list