Callback Function Fatal Error: Unsupported operand types in
<?php
$A= array("A1"=>array("x"=>1,"b"=>2,"d"=>3,"s"=>8),
"A2"=>array("a"=>4,"b"=>3,"c"=>2,"d"=>1)
);
function callback($a, $b) { return $a + $b; }
$keys = array_keys(array_reduce($A, "callback", array()));
sort($开发者_Go百科keys);
echo '<pre>';
print_r($keys);
echo '</pre>';
What am I wrong here?Because I got message:
Fatal error: Unsupported operand types in .... in line
Cannot reproduce, I dont get an error, if I execute your code. But it seems, that you just want to get the unique keys.
$keys = array_unique(array_merge (array_keys($A['A1']), array_keys($A['A2'])));
精彩评论