PHP an array of arrays to one string or one BIG ARRAY -


this code opens excel files in folder gets emails in file opened , puts them in array. in end need 1 big array content array of arrays. need 1 big array of emails files.

the code below not working. sure simple one. thanks

<?  $folder = "sjc/"; $files = scandir($folder);   function cleanfolder($file) { $string = file_get_contents("sjc/$file"); $pattern = '/[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,3})(?:\.[a-z]{2})?/i'; preg_match_all($pattern, $string, $matches);  $emails[] = $matches[0]; return $emails; }    function beginclean($files) {     for($i=0; count($files)>$i;$i++)         {         $emails = cleanfolder("$files[$i]");         $theemails .= explode(",",$emails);          }  /// supposed big string of emails separated comma echo $theemails; // echos .... arrayarrayarrayarrayarray etc...  // want is.. 1 array holding emails, not array of arrays.  }  beginclean($files);  ?> 

update: got tot work.. having memory issue emails total on 229911.

fatal error: allowed memory size of 67108864 bytes exhausted (tried allocate 71 bytes) in /home/public_html/statuesplus/cleanlistfolder.php on line 33

here code worked:

<?  $folder = "sjc/"; $files = scandir($folder);   function cleanfolder($file) { //echo "file name " . $file . "<br>"; $string = file_get_contents("sjc/$file"); $pattern = '/[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,3})(?:\.[a-z]{2})?/i'; preg_match_all($pattern, $string, $matches);  $theemails .= implode(',', $matches[0]); return $theemails;  }    function beginclean($files) {     for($i=0; count($files)>$i;$i++)         {         $emails .= cleanfolder("$files[$i]");         }    $theemails = explode(",", $emails); //$uniqueemails= array_unique($theemails); echo count($theemails); //file_put_contents("emails.txt", $theemails); }  beginclean($files);  ?> 

.= used concatenating strings, not arrays. can keep them strings while:

$theemails .= ",$emails"; 

and then:

$theemails = explode(',', substr($theemails, 1)); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -