I have several arrays stored in a variable. My variable holds these arrays:
Array ( [0] => firstname [1] => lastname [2] => email [3] => phone )
Array ( [0] => Benny [1] => Mose [2] => [email protected] [3] => 12345678 )
Array ( [0] => Luke [1] => Skywalker [2] => [email protected] [3] => 10000000 )
Array ( [0] => Master [1] => Yoda [2] => [email protected] [3] => 13370002 )
Array ( [0] => Ben [1] => Kenobi [2] => [email protected] [3] => 13370004 )
Array ( [0] => Darth [1] => Bandon [2] => [email protected] [3] => 55554444 )
Array ( [0] => C-3PO [1] => Robot [2] => [email protected] [3] => 33339999 )
Array ( [0] => R2D2 [1] => Robot [2] => [email protected] [3] => 44447777 )
Array ( [0] => Han [1] => Solo [2] => [email protected] [3] => 99998888 )
Array ( [0] => Jar jar [1] => Binks [2] => [email protected] [3] => 111112222 )
I want to display the first[0] and third[2] value for every array.
I'm able to display the first value for each array by using:
$CSVfp = fopen("csv-list.csv", "r");
if($CSVfp !== FALSE) {
while(! feof($CSVfp)) {
$data = fgetcsv($CSVfp);
echo '<hr>';
foreach($data as $arr)
{
echo $data[0].' '.$data[1].', '.$data[2].'<br>'; // first element
}
}
}
fclose($CSVfp);
But I can't figure out how to display both first and third value.