0

i m storing data from excel into database and

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

this each cell has two values like "23 43.12" and i want to store only the second value of each cell.

I tried using explode to separate it but its not getting separated from one of the previous queries EXPLODE(Splitting up a string in PHP with every blank space)

$value1 = explode(" ", $rowDataA[0][0]);
    echo $value1[0]; // piece1
    echo $value1[1]; 

from value1[0] m getting 23 43.12 and from value1[1] m getting undefined offset 1

Sascha
  • 4,576
  • 3
  • 13
  • 34

1 Answers1

1

If that space is creating issue just replace it with some other character or the normal space itself and then use explode

 $rowDataA = $sheet->rangeToArray('L' . $row . ':'. 'M' . $row, NULL, TRUE, FALSE);
    $str1 = preg_replace('/\s+/', ' ', $rowDataA[0][0]);
    $value1 = explode(' ', $str1);
    echo $value1[1];