473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Merging unknown arrays

Hi!

Is there a better way to do this?

$command = '$array = array_merge($array[\'' .
implode('\'],$array[\'',array_keys($array)) . '\']);';
eval($command);

Regards,
André
Jan 16 '06 #1
3 1760
André Hänsel said the following on 15/01/2006 23:57:
Hi!

Is there a better way to do this?

Well, you haven't said what "this" is - what are you trying to do?
$command = '$array = array_merge($array[\'' .
implode('\'],$array[\'',array_keys($array)) . '\']);';
eval($command);

From your code, I'm guessing that you want to convert an array of
arrays into a single array. How about:

$result = array();
foreach ($array as $a)
{
$result = array_merge($result, $a);
}

--
Oli
Jan 16 '06 #2
André Hänsel wrote:
Is there a better way to do this?

$command = '$array = array_merge($array[\'' .
implode('\'],$array[\'',array_keys($array)) . '\']);';
eval($command);


$array = array_values($array);
JW
Jan 16 '06 #3
$array = call_user_func_array('array_merge', $array);

Jan 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tmenke | last post by:
Can someone help, I have two arrays and want to merge them into a third array.What I want to do is, after I create this third array (combination of the first two) is to erase the original two...
3
by: Maarten van Reeuwijk | last post by:
Hello, I am using the Numeric package, and I need to strip edge cells off an array (dimension unknown) in an a-priori unknown direction. I implented this as follows: def el_remove_bcells(var,...
4
by: Bush will disarm all workers next | last post by:
I'm new to JavaScript. So please excuse my mistakes. I need help on merging two arrays into a third one. There is an array a = {188, 180, 159, 67 } There is another array b={'Rio de Janeiro', 'Sao...
0
by: PeterW | last post by:
I have a class which uses three other classes, two of which are used in arrays. This class is only ever used for incoming messages. All classes inherit from ISerializable and impliment...
8
by: vidishasharma | last post by:
Can somebody suggest good URL which contains code for merging of 2 or more priority queues in c#.
5
by: John | last post by:
Hi Is there a way to merge two or more single dimension string arrays into a single, single dimension string array? Thanks Regards
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
1
by: chiefychf | last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge...
1
by: kliopatraisis | last post by:
I think I've been working on this assignment for too long and my brain has stopped making connections! Basically, we are making a very simple version of AutoCAD, called HomeCAD. The problem I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.