New to PHP !! Below is a piece of PHP code: & lt ;? Php $ aarray (name & nbsp; & gt; & nbsp; ($ d & nbsp; array (cat) & nbsp;, Monday & nbsp; & gt; (& nbsp; $ c & nbsp; array (dog) & nbsp;); array_push PHP beginner, please advise !!
The following is a piece of PHP code:
$ A = array ("name" => ($ d = array ("cat"), "Monday" => ($ c = array ("dog ")));
Array_push ($ d, "Horse", "Bird ");
Print_r ($ );
?>
The running result is:
I want to know if I have used the array_push function. why is there no problem when "Horse" Bird "values are output?
How can I change the values to be appended ??
Thank you !!
Share: More
------ Solution --------------------
What is your $ d and $ c? Array_push () is to push one or more units to the end of the array (into the stack ).
Your usage is incorrect!
------ Solution --------------------
You print_r ($ d );
array_push($a['name'],"Horse","Bird");
print_r ($a);
Array
(
[Name] => Array
(
[0] => cat
[1] => Horse
[2] => Bird
)
[Monday] => Array
(
[0] => dog
)
)