Array merge

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sandy1028
Forum Commoner
Posts: 60
Joined: Thu Jul 26, 2007 3:56 am

Array merge

Post 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]
Hemlata
Forum Commoner
Posts: 35
Joined: Mon Sep 10, 2007 5:40 am
Location: India
Contact:

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Your code already has 1 array: $listCentr. Not sure which arrays you're talking about that you'd like to merge together.
Last edited by pickle on Fri Sep 14, 2007 3:26 pm, edited 1 time in total.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply