Forum Moderators: coopster

Message Too Old, No Replies

collapse an array of arrays

turn multtid array into one d

         

shumboom

2:17 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



Hi

newbie here and unsure which array function to use.

I have an array of arrays such as

(0=>0 1 2) (1=>4 3 5 6) (2=>3 4 7 8 9)

which I would like to be a single dimension array of

(0 1 2 4 3 5 6 3 4 7 8 9 )

Whats the most efficient way of doing this?

Also what is the best way of removing a number of elements from an array
eg
$arr1=array(0 4 5 8 9 10 )
$arr2=array ( 5 8)

remove($arr1,$arr2) gives me

0 4 9 10

thanks ins advance
Shumit

PokeTech

2:46 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



Well is this what you're trying to do:

$arr = array(
"0" => "0 1 2",
"1" => "4 3 5 6",
"2" => "3 4 7 8 9"
);

then you can do this:

$arr[0] //returns 0 1 2

and so on for the rest.

I'm not really understanding exactly what you want done but thats the basics of arrays.

[edited by: PokeTech at 2:47 pm (utc) on June 28, 2008]

shumboom

3:26 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



I want to remove the dimensions from the array so that

array[0] gives me the all the values from all the arrays .

I think I need to do an array_merge between all the elements of the array but not sure how to do it without using a loop.

thanks