Combining two arrays of different type. |
Combining two arrays of different type. |
tudsy |
Jan 11 2017, 09:36 AM
Post
#1
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
Hi
Just a little problem. How do I combine an array of filenames with an array of numbers? That is, $filenames =array("file1", .........); $numbers = array("23",..............); Any help will be appreciated. Thanks. |
Christian J |
Jan 11 2017, 09:49 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,665 Joined: 10-August 06 Member No.: 7 |
Do you mean merge them, or something else?
|
tudsy |
Jan 11 2017, 10:23 AM
Post
#3
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
|
Christian J |
Jan 11 2017, 02:29 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,665 Joined: 10-August 06 Member No.: 7 |
An array may contain values of different types, so array_merge() should work.
Both your arrays use string values though, since "23" is a string too (unlike 23 without quotes). |
CharlesEF |
Jan 11 2017, 06:09 PM
Post
#5
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
If you want the array in the exact order as your sample, then I think you need to write your own function. array_merge() will work if you don't mind appending the 2nd array to the end of the 1st array.
|
Lo-Fi Version | Time is now: 13th May 2024 - 01:09 AM |