note 40188 added to control-structures.foreach
| From: | injunjoel at rn2 dot php dot net | Date: | Tue, 24 Feb 2004 19:30:43 +0000 |
| Subject: | note 40188 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65662@lists.php.net to get a copy of this message | ||
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...
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40188
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40188&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40188&report=yes
Search -- http://master.php.net/manage/user-notes.php