note 40188 deleted from control-structures.foreach by nlopess
| From: | nlopess@php.net | Date: | Tue, 24 Feb 2004 19:32:49 +0000 |
| Subject: | note 40188 deleted from control-structures.foreach by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65663@lists.php.net to get a copy of this message | ||
Note Submitter: injunjoel
----
I have read many of the examples for merging two arrays in PHP. Here is what I do.
Code example:
<?php
/* our test arrays */
$array1 = array(1,2,3,4);
$array2 = array('one','two','three','four');
/* lets merge shall we */
foreach($array2 as $elm){
array_push($array1, $elm);
}
print_r($array1);
?>
Output:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => one
[5] => two
[6] => three
[7] => four
)
Hope that helps someone...