Php 将JSON字符串转换为数组
我有这个JSON字符串Php 将JSON字符串转换为数组,php,arrays,json,function,Php,Arrays,Json,Function,我有这个JSON字符串 {"ticker":{"high":736.45099,"low":681,"avg":708.725495,"vol":13038780.63684,"vol_cur":18382.55965,"last":726,"buy":726,"sell":724.5,"updated":1388242741,"server_time":1388242743}} 在执行json\u decode()之后,如何获取“last”参数 <?php $json='{"ticke
{"ticker":{"high":736.45099,"low":681,"avg":708.725495,"vol":13038780.63684,"vol_cur":18382.55965,"last":726,"buy":726,"sell":724.5,"updated":1388242741,"server_time":1388242743}}
在执行json\u decode()
之后,如何获取“last”参数
<?php
$json='{"ticker":{"high":736.45099,"low":681,"avg":708.725495,"vol":13038780.63684,"vol_cur":18382.55965,"last":726,"buy":726,"sell":724.5,"updated":1388242741,"server_time":1388242743}}';
$json_arr=json_decode($json,true);
echo $json_arr['ticker']['server_time'];//"prints" 1388242743 which is the last param "server time"
你喜欢这样做吗
<?php
$json='{"ticker":{"high":736.45099,"low":681,"avg":708.725495,"vol":13038780.63684,"vol_cur":18382.55965,"last":726,"buy":726,"sell":724.5,"updated":1388242741,"server_time":1388242743}}';
$json_arr=json_decode($json,true);
echo $json_arr['ticker']['server_time'];//"prints" 1388242743 which is the last param "server time"
使用json\u decode和参数json string和TRUE。如果为TRUE,返回的对象将转换为关联数组
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json, true));
?>
使用参数json字符串和TRUE的json\u decode。如果为TRUE,返回的对象将转换为关联数组
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json, true));
?>
$jsonArray=json_decode(“…”,true)echo$jsonArray['ticker']['last']
$jsonArray=json_decode('…',true)echo$jsonArray['ticker']['last']
实际上,op询问如何获取名为“last”
的参数。除此之外,这个答案是正确的。我也以类似的方式思考,因此+1.:)实际上,op要求获取名为“last”
的参数。除此之外,这个答案是正确的。我也以类似的方式思考,因此+1.:)