Questions about the PHP array_unshift function
This post was last edited by Eiysxd on 2014-08-22 23:07:03
The Array_unshift function is to throw arguments to the front of the array, but why not?
$forums [$key] [' level '] + = 1;
I used the print_r to output
Array ([FID] = 2 [Fup] = 1 [name] + test [displayorder] = 0 [Threads] + 2 [posts] = 2 [todayposts] + 0 [Allparent] = = Array ([0] = 2) [Allnodes] = Array ([0] = 2) [level] = 1)
$fup = 1
Then this code array_unshift ($forums [$key] [' Parent '], $fup);
I'm looking at the Print_r output.
Array ([FID] = 2 [Fup] = 1 [name] + test [displayorder] = 0 [Threads] + 2 [posts] = 2 [todayposts] + 0 [Allparent] = = Array ([0] = 1 [1] + 2) [allnodes] = = Array ([0] + 2) [level] = 1 [Parent] =)
May I ask why the parent = is empty?? Isn't it supposed to be [Parent]=>array (0]=>1) like this??
------Solution--------------------
It is possible that the parent in the array was not found in the first attempt.
$fup =array (Array (' parent ' =>1));
Array_unshift ($forums [$key], $fup);
------Solution--------------------
Where is the $forums [$key] [' parent '] defined? Why didn't I see it?
Your Array_unshift ($forums [$key] [' Parent '], $fup); A Warning error will be generated:
Array_unshift () expects parameter 1 to is array, null given
But you're proud to reject PHP's help.