0

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

Therefore i can do an IF statement and echo a different piece of text for when there's no JSON available?

2 Answers 2

1
$data = json_decode("some json");
echo count($data);
Sign up to request clarification or add additional context in comments.

1 Comment

how about if your json has 1 extra level... would you do count($data[0]) for ex?
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.