note 113714 added to function.array-push
| From: | flobee | Date: | Wed, 20 Nov 2013 13:25:09 +0000 |
| Subject: | note 113714 added to function.array-push | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197571@lists.php.net to get a copy of this message | ||
Be warned using $array "+=" array(1,2,3) or union operations
(http://php.net/manual/en/language.operators.array.php)
I think it worked in the past or i havent test it good enough. :-/
(once it worked, once [] was faster than array_push, the past :-D ):
php -r '$a = array(1,2); $a += array(3,4); print_r($a);'
Array (
[0] => 1
[1] => 2
)
php -r '$a = array(1,2); $b = array(3,4);$c = $a + $b; print_r($c);'
Array (
[0] => 1
[1] => 2
)
php -r '$a = array(1,2); $b = array(2=>3,3=>4);$c = $a + $b; print_r($c);'
Array (
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/function.array-push.php
Edit -- https://master.php.net/note/edit/113714
Del: integrated -- https://master.php.net/note/delete/113714/integrated
Del: useless -- https://master.php.net/note/delete/113714/useless
Del: bad code -- https://master.php.net/note/delete/113714/bad+code
Del: spam -- https://master.php.net/note/delete/113714/spam
Del: non-english -- https://master.php.net/note/delete/113714/non-english
Del: in docs -- https://master.php.net/note/delete/113714/in+docs
Del: other reasons-- https://master.php.net/note/delete/113714
Reject -- https://master.php.net/note/reject/113714
Search -- https://master.php.net/manage/user-notes.php