-2

I have an array of arrays formatted like the following:

$list = [ ["fdsa","1","fdsa"],["sadf","0","asdf"],["frfrf","0","sadfdsf"] ]

How can I loop through every single value?

nietonfir
  • 4,797
  • 6
  • 31
  • 43
nshah
  • 597
  • 2
  • 9
  • 30
  • possible duplicate of [Alphabetize array of arrays PHP](http://stackoverflow.com/questions/19391474/alphabetize-array-of-arrays-php) – andrewsi Oct 16 '13 at 03:09

2 Answers2

3

With a RecursiveIteratorIterator?

foreach(new RecursiveIteratorIterator(new RecursiveArrayIterator($list)) as $item){
        var_dump($item);
}

string(4) "fdsa"
string(1) "1"
string(4) "fdsa"
string(4) "sadf"
string(1) "0"
string(4) "asdf"
string(5) "frfrf"
string(1) "0"
string(7) "sadfdsf"

... unless you want it more structured...

Wrikken
  • 69,272
  • 8
  • 97
  • 136
-2

Try:

$array = array(array("!","Hello","World"));
foreach($array as $key){
    $myvar = $key[0];
    $myvar2 = $key[1];
    $myvar3 = $key[2];
}

UPDATED!

Hope it helped!

Federico Piragua
  • 707
  • 7
  • 13
  • And what do you do if there's an array in an array in an array? Add another loop? Or will you then start looking at recursive functions? – nietonfir Oct 15 '13 at 21:47