I don’t know any PHP so another developer helped me out with this code. I am trying to return the names of all the files in a folder on my server. These are then passed to my iPhone app which uses the data. However, I have 160 files in the folder and the JSON string only returns 85. Is there something wrong with this code:
<?php
$path = 'Accepted/';
# find all files with extension jpg, jpeg, png
# note: will not descend into sub directorates
$files = glob("{$path}/{*.jpg,*.jpeg,*.png}", GLOB_BRACE);
// output to json
echo json_encode($files);
?>
There is no reason this code should fail. However, your
$pathvariable should not end in a slash (as you have that in theglobcall).Things to look at:
print_ron the$filesvariable. It should list all the matched files. See if you can identify the files that aren’t listed.