note 76596 deleted from function.array-merge by salathe
| From: | salathe@php.net | Date: | Mon, 06 Sep 2021 22:44:36 +0000 |
| Subject: | note 76596 deleted from function.array-merge by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216884@lists.php.net to get a copy of this message | ||
Note Submitter: clancyhood at gmail dot com
----
Similar to Jo I had a problem merging arrays (thanks for that Jo you kicked me out of my debugging
slumber) - array_merge does NOT act like array_push, as I had anticipated
<?php
$array = array('1', 'hello');
array_push($array, 'world');
var_dump($array);
// gives '1', 'hello', 'world'
$array = array('1', 'hello');
array_merge($array, array('world'));
// gives '1', 'hello'
$array = array('1', 'hello');
$array = array_merge($array, array('world'));
// gives '1', 'hello', 'world'
?>
hope this helps someone