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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -