Using the code below it doesn't work but when I use
<?php
$GLOBALS['players'] = array();
function add($name) {
$array = $GLOBALS['players'][$name] = array();
array_push($array, "b");
}
add("a");
print_r($players);
?>
(outputs: Array ( [a] => Array ( ) )) the code here
<?php
$GLOBALS['players'] = array();
function add($name) {
$array = $GLOBALS['players'][$name] = array();
array_push($GLOBALS['players'][$name], "b");
}
add("a");
print_r($players);
?>
(outputs: Array ( [a] => Array ( [0] => b ) )) it works fine. Why does $array not work when it is referencing the same array.