0
Let’s say we have a JSON with 2 elements to follow:
exemplo: {
[{
"arquivo": "Arquio 1",
"size": "2340"
}, {
"arquivo": "Arquivo 2",
"size": "0"
}, {
"arquivo": "arquivo 3",
"size": "4329"
}
Use PHP for() to make a list of files.
For example:
for($i=0; $i<=10; $i++)
{
$arquivo = $json->exemplo[$i]->arquivo;
$size = $json->exemplo[$i]->size;
echo "Nome: ".$nome." - ".$size."<br />";
}
What I want to do is ignore files from the list that are in size(size) "0" and leave only those larger than 0 before going to for() PHP.
Can someone help me?
Thank you for your reply! Let’s say: if you have 3 results and these 3 are with size 0, then inside the for() will be blank. Can you change this so it doesn’t go blank? or return an error msg if all results are size 0
– user41630
It is, if all elements are invalid, the array is empty. What you want to occur in this case?
– mau humor
Here’s an example: http://goo.gl/1iVZBg see that everything is empty when all is empty, and like if everything is empty, you can return an error msg?
– user41630
You have yes, after for: if (Count($json->example)=0) ː echo "No file"; }
– mau humor
Thank you! I’ll test.
– user41630
It helped.. Thank you!
– user41630