I have created an array. Then I have made call to a function. That function adds another array inside this array. But it is returning an empty array when I print_r
the main array. Please note that the reason to use function
is that I intend to call it multiple times.
PHP
:
$myarray = array();
myfunc();
function myfunc() {
$a = 1;
$b = "my name";
$myarray[] = array(
'a'=>$a,
'b'=>$b
);
}
print_r($myarray);