3
How can I find out the amount of elements of a json file through PHP.
See the example of my file:
[{"descricao":"Fotografia","codigo":784},{"descricao":"Filmagem","codigo":789}]
I would like to check the amount of elements, which in this case should be 2, I tried to perform a json_decode before to try to manipulate the json, but always returns me a NULL. And with the sizeof returns me only the value 1.
was what I had been trying, but it only works if I use a utf8_encode($str_json) before json_decode(). Vlw
– tkmtts
Did you get @tkmattos? I just really tested with this json and it’s okay
– Miguel
If you’re having to use
utf8_enconde()
, then why not open the file with the notepad and check if it is saved as ANSI. If you are switching to UTF-8 and remove PHP functions.– StillBuggin
It worked @Miguel, perfect
– tkmtts
@Eduardoalmeida json comes from a webservice
– tkmtts
You’re welcome @tkmattos
– Miguel