I have the following code.
$resu = array_map(function($aVal, $bVal){
return "$bVal [$aVal]";
}, $result, $intersect);
$sorAr = array();
array_walk($resu, function($element) use (&$sorAr) {
$parts = explode(" ", $element);
$sorAr[$parts[0]] = trim($parts[1], ' []');
});
The problem lies when i need to use the anonymous function in both variable $resu and on array_walk. the error shows as follows
Parse error: syntax error, unexpected T_FUNCTION in /dir...
I try to read on this site different suggestion but no luck. how do i solve this problem. Some one help please?
I have tried this code...
function arrSwap() {
$arraySwap = function($aVal, $bVal){
return "$bVal [$aVal]";
};
$resu = array_map($arraySwap, $result, $intersect);
}
$sorAr = array();
function arrSwap2() {
$arrayWalk = function($element) use (&$sorAr) {
$parts = explode(" ", $element);
$sorAr[$parts[0]] = trim($parts[1], ' []');
};
array_walk($resu, $arrayWalk);
}
but i get this error...
Fatal error: Cannot redeclare arrSwap() (previously declared in on line 100... which the line 100 is this -> function arrSwap() {