php - List Directories in Json File -
i can list images folder in json using code below:
<?php $dir = "images/friday/"; $images = glob($dir."*.jpg"); foreach($images $image){ $registro = array( "file" => $image ); $retorno[] = $registro; } $retorno = json_encode($retorno); echo $retorno; ?>
i think work directories nothing displayed if don´t use print_r($dirs).
<?php $path = "images"; $dirs = glob($path . "/*", glob_onlydir); foreach($dirs $dir){ $reg = array( "folder" => $dir ); $return[] = $reg; } $return = json_encode($return); echo $return; ?>
echo $return not display anything. there simple workaround or have build function? need "folder" identifier.
Comments
Post a Comment