Page 1 of 1

Array merge

Posted: Fri Sep 14, 2007 6:55 am
by sandy1028
pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


How to merge these arrays.

[syntax="php"]$listCentr = explode(":",$centres);

$listCentr[0]
$listCentr[1]
$listCentr[2]

Please help how to merge these to single array


pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Sep 14, 2007 7:00 am
by Hemlata
Hello sandy1028,

Use php pre-defined function 'array_merge'. See the use on http://in2.php.net/manual/en/function.array-merge.php

Posted: Fri Sep 14, 2007 3:01 pm
by pickle
Your code already has 1 array: $listCentr. Not sure which arrays you're talking about that you'd like to merge together.

Posted: Fri Sep 14, 2007 3:25 pm
by s.dot
Yes, it is already in one array when you explode()'d on it.

Unless you mean getting it back into the string it was in by implode()ing.