开发者

mysql_num_rows equivalent for JSON in PHP

Can you do a similar test when returning JSON with PHP like mysql_num_rows?

Therefore i can do an IF stat开发者_JAVA技巧ement and echo a different piece of text for when there's no JSON available?


$data = json_decode("some json");
echo count($data);


Not sure what the context is but you can do

$array = json_decode($json_string);
$num = count($array);

That's if the json_string is an array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜