Malloc
Malloc

Reputation: 16286

displaying the content of an array which is composed of two other arrays

i have an array like this :

$finalArray= array($array1, $array2);

later, how should i do to display the content of $finalArray in a loop without knowing the name of the columns of $array1 and $array2 ? thx in advance :)

EDIT i.e : to display the content of a simple array we do something like that :

foreach($array1 as $value){
         echo $value['the_name_of_the_columns']."<br />";
       }

how about an array of arrays :), i'm supposed to having to know the name of columns, i need to it independently on the columns names .

Upvotes: 0

Views: 40

Answers (1)

fingerman
fingerman

Reputation: 2470

use foreach....

echo "first: <br/>";
foreach ($finalarray[0] as $value) {
    echo "Value: $value<br />\n";
}
echo "second: <br/>";
foreach ($finalarray[1] as $value) {
    echo "Value: $value<br />\n";
}

EDIT :

documentation on foreach: http://php.net/manual/en/control-structures.foreach.php

Upvotes: 1

Related Questions