这是我的调试代码:
echo $val2[ $key ];
echo $val2[ 0 ];
echo $val2[ "0" ];
var_dump( $val2 );
die();
这是输出:
Notice: Undefined offset: 0 in index.php on line 319
Notice: Undefined offset: 0 in index.php on line 320
Notice: Undefined offset: 0 in index.php on line 321
array(1) { ["0"]=> float(0.123) }
这让我发疯了,为什么说明显没有钥匙?
答案 0 :(得分:0)
问题来自
$val2 = (array) json_decode( $data );
应该是:
$val2 = json_decode( $data, true );