phpphpexcelreader

how to get the values separatedly when multiple column value are stored in a row of excel in php


enter image description here

This is my excel sheet from where m trying to get the L and M column but only the second value in my case the values are L6= 3.74 and M6= 457.27 This is my current code

$sheet = $objPHPExcel->getSheet();
$highestRow = $sheet->getHighestRow();
for ($row=5; $row <= $highestRow; $row++) 
{ 
    $rowData = $sheet->rangeToArray('B' . $row . ':'. 'B' . $row, NULL, TRUE, FALSE); 
    $rowDataA = $sheet->rangeToArray('L' . $row . ':'. 'M' . $row, NULL, TRUE, FALSE);
    print_r($rowDataA);
}

this is what print_r returns Array ( [0] => Array ( [0] => 23 3.74 [1] => 721 457.27 ) ) is there anyway i can get 3.74 and 457.27 only and not the first value


Solution

  •  $rowDataA = $sheet->rangeToArray('L' . $row . ':'. 'M' . $row, NULL, TRUE, FALSE);
     $value1 = explode(' ', $rowDataA[0][0]);
     echo $value1[1];
    

    This is what can be done and alternatively if that somehow does not work replace space with something else and then use explode function and it will work.

    $rowDataA[0][0] = preg_replace('/\s+/', ' ', $rowDataA[0][0]);