$values = (object)$arr;
var_dump($values);
var_dump 产生这些:
object(stdClass)[1]
public 'time' => float 0.002
public 'distance' => float 0.156
public 'code' => string '1' (length=1)
public 'result' =>
array (size=17)
0 => string '2.94053, 101.787, A' (length=24)
1 => string '2.94043, 101.787, A' (length=24)
2 => string '2.9404, 101.787, A' (length=23)
3 => string '2.94029, 101.787, A' (length=24)
4 => string '2.94025, 101.787, A' (length=24)
5 => string '2.9402, 101.787, A' (length=23)
6 => string '2.94016, 101.787, A' (length=24)
7 => string '2.94007, 101.787, A' (length=24)
public 'arrayPosition' =>
array (size=1)
0 =>
array (size=1720)
0 => string '2.93955, 101.788, B' (length=22)
1 => string '2.93951, 101.788, B' (length=22)
2 => string '2.93926, 101.788, B' (length=22)
3 => string '2.93921, 101.788, B' (length=22)
4 => string '2.9392, 101.788, B' (length=21)
5 => string '2.93911, 101.788, B' (length=22)
6 => string '2.93906, 101.789, B' (length=22)
7 => string '2.93896, 101.789, B' (length=22)
如何读取result
和的每个值arrayPosition
?通过使用这个
echo "<br>".$values->time."<br>";
echo $values->distance."<br>";
echo $values->code."<br>";
echo $values->result."<br>";
echo $values->arrayPosition."<br>";
将失败result
并且arrayPosition
Notice: Array to string conversion