![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hello, I would like to combine two arrays: e.g. $array1 = array(1,2,3,4); $array2 = array('cat', 'dog', 'duck', 'fly'); The resulting array should be: '1 cat', '2 dog', '3 duck', '4 fly' Is there a function that does this automatically kinda similar of array_merge? Greetz, Barton | |||
| | #2 | ||
| You could just make your own function: $array1 = array(1,2,3,4); $array2 = array('cat', 'dog', 'duck', 'fly'); $new = new_array($array1, $array2); function new_array($array1, $array2) { // The new function $new = array(); for ($i = 0 ; $i < count($array1) ; $i++) { $str = $array1[$i] . ' ' . $array2[$i]; array_push($new, $str); } return $new; } "Barton" <bc173@NOSPAMMMhotmail.com> wrote in message news:9d8jfv4nikfcf149blkupgdep4blsnitne@4ax.com... > Hello, > > I would like to combine two arrays: > > e.g. > > $array1 = array(1,2,3,4); > $array2 = array('cat', 'dog', 'duck', 'fly'); > > The resulting array should be: > > '1 cat', '2 dog', '3 duck', '4 fly' > > Is there a function that does this automatically kinda similar of > array_merge? > > Greetz, > > Barton > | |||
| Featured Websites | ||||
|
![]() |
| Tags: arrays, combine, two |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AWESOME-Combine ebay and MLM -what a concept | gourmetcandlegal | General Ebay Questions And Answers | 1 | 05-30-2007 1:01 AM |
| AWESOME-Combine ebay and MLM -what a concept | gourmetcandlegal | General Ebay Questions And Answers | 6 | 05-30-2007 1:00 AM |
| [PEAR-DEV] Associative arrays and PEAR SOAP | Adam Ashley | Pear | 0 | 05-20-2007 7:41 PM |
| Featured Websites | ||||
|