Dynamically create a file from PHP -


i cycling through unknown number of json files, reading contents, adding information want variables, want write information separate files.

here code:

$directory = '../filepath\*'; // each file in directory found,  // place in array variable $file foreach(glob($directory) $file){     // each file found, contents     $jsoncontents = file_get_contents($file);     // have contents, decode json , array php can read     $jsondecode = json_decode($jsoncontents, true);      $person= '';     $information= '';      // each file has been decoded,     // find person data , display person id , information     foreach($jsondecode['smsdata']['datainfo']['data'] $value){         $person = $value['person'];         $information = $value['information'];         // if $person not empty, create file, else, nothing         if($person != ''){             file_put_contents('../filepath/somewhere'.$person . '.txt', $information);         } else {             //do nothing!         }     } } 

i wanting create each file $person id , put $information inside file don't think have format save files correct.

edit: should point out not getting output this.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -