Receiving error when appending to $_SESSION array
Posted: Tue Nov 30, 2004 12:48 pm
Code: Select all
$_SESSION['itn'][]=$session_array;Shouldn't this append the array $session_array to $_SESSION['itn'] array?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$_SESSION['itn'][]=$session_array;Code: Select all
<?php
$myarray = array("foo"=>"", "bar"=>"bar_data");
$otherarray = array("data1"=>"Maugrim", "data2"=>"Reaper");
$myarray['foo'] = $otherarray;
echo $myarray['foo']['data1'];
// echoes "Maugrim"
?>Code: Select all
<?php
$myarray = array("foo"=>array());
$otherarray = array("data1"=>"Maugrim", "data2"=>"Reaper");
array_push($myarray['foo'], $otherarray);
echo $myarray['foo']['0']['data1'];
// echoes "Maugrim"
?>Code: Select all
$posted_array = array ( [0] => 12, [1] => 13) ;
array_merge($_SESSION['itn'], $posted_array);
// this generates a 'Warning: array_push(): First argument should be an array' error