I'm trying to declare a global array and put data in it with a function.
It works only if the global variable is a string but not if it's an array:
$data = iterate("USER361");
print_r($data);
function iterate($username)
{
global $gv_array;
$sql = "select * from account where sponsor = '$username'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$this_user = $row['username'];
$this_name = $row['full_name'];
$this_tier = $row['tier'];
$my_array = array("username"=>$this_user,"name"=>$this_name,"tier"=>$this_tier);
array_push($gv_array[],$my_array);
iterate($row['username']);
}
}//end of iterate
The error I get is:
PHP Warning: array_push() expects parameter 1 to be array, null given in /var/www/html/inc/code.php on line 29