Balakumar B
Balakumar B

Reputation: 790

Multidimensional array - how to get specific values from array

I have converted Excel data into Php array using toArray()..

actually my result is

enter image description here

My question how to get value from this Multidimensional array? and also how to i get header and value from array in separately?

enter image description here

Upvotes: 0

Views: 337

Answers (3)

Tirthraj Barot
Tirthraj Barot

Reputation: 2679

If you are trying to extract all the values of specific key then you should use for or foreach or while loop...

its something like

<?php 
$array = YOUR ARRAY;
$c=count($array);
for ( $i=0; $i < $c; $i++)
{ 
    echo $array[$i]['StudentName'];
 } 
?>   

else if you want to get a specific value manually You can easily traverse to your value as

$array = YOUR ARRAY 
echo $ara['Worksheet'][0]['StudentName']

Upvotes: 0

sonique
sonique

Reputation: 4762

you can access value, by following the path of the array. so in your case : $yourArrayName['Worksheet'][0][0], will return SNo

Upvotes: 1

Nick
Nick

Reputation: 10143

Get one value:

print_r($your_array['Worksheet'][0]);

Get values with loop:

foreach ($your_array as $key => $value)
{
    echo $key; // 'Worksheet'
    print_r $value;
}

Upvotes: 0

Related Questions