I guess you want to loop on array $a
, each one of whose elements are also arrays.
When you loop $array there is one item whose info is the one you said:
Array (
[1173627548] => Array (
[num] => 1173627548
[methv] => dont know
[q1] => -
[q2] => -
[q3] => U
[q4] => -
[comm] =>
)
)
If you want to access methv
element you should do the following:
foreach($array as $a){
echo $a["methv"]; // this would access $array[ 1173627548 ][ "methv" ]
}
While the foreach continues you will keep accessing to all $array[ ][ "methv" ]
values
Hope it helps.
Based on your comment indicating the print_r($array)
.
First of all, let me indent it so that we get a better overview of the array:
Array (
[0] => Array (
[1173627548] => Array (
[num] => 1173627548
[methv] => dont know
[q1] => -
[q2] => -
[q3] => U
[q4] => -
[comm] =>
)
)
[1] => Array (
[1182868902] => Array (
[num] => 1182868902
[methv] => dont know
[q1] => -
[q2] => -
[q3] => U
[q4] => -
[comm] => )
)
)
Array (
[0] => Array (
[1173627548] => Array (
[num] => 1173627548
[methv] => dont know
[q1] => -
[q2] => -
[q3] => U
[q4] => - [comm] =>
)
)
[1] => Array (
[1182868902] => Array (
[num] => 1182868902
[methv] => dont know
[q1] => -
[q2] => -
[q3] => U
[q4] => -
[comm] =>
)
)
)
I guess you are printing it twice, because we can see two exactly arrays one after the other.
If you want to get [methv]
item, what you need is to access:
$array[ 0 ][ 1173627548 ][ "methv" ]
$array[ 1 ][ 1182868902 ][ "methv" ]
So what you can do is to use foreach
twice:
foreach ($array as $a) {
foreach ($a as $v) {
echo $v[ "methv" ];
}
}