note 61217 added to function.array-push

From: Date: Sat, 28 Jan 2006 14:06:41 +0000
Subject: note 61217 added to function.array-push
Groups: php.notes 
Request: Send a blank email to php-notes+get-102619@lists.php.net to get a copy of this message
If you push an array onto the stack, PHP will add the whole array to the next element instead of adding the keys and values to the array. If this is not what you want, you're better off using array_merge() or traverse the array you're pushing on and add each element with $stack[$key] = $value. <?php $stack = array('a', 'b', 'c'); array_push($stack, array('d', 'e', 'f')); print_r($stack); ?> The above will output this: Array ( [0] => a [1] => b [2] => c [3] => Array ( [0] => a [1] => b [2] => c ) ) ---- Server IP: 216.194.113.175 Probable Submitter: 65.100.200.115 ---- Manual Page -- http://www.php.net/manual/en/function.array-push.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61217 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61217&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61217&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102619) next »