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.
精彩评论