Skip to content

Instantly share code, notes, and snippets.

@ulyssesr
Created November 20, 2017 18:02
Show Gist options
  • Save ulyssesr/3efdccce8eefc3a8a22a0e54476bdf61 to your computer and use it in GitHub Desktop.
Save ulyssesr/3efdccce8eefc3a8a22a0e54476bdf61 to your computer and use it in GitHub Desktop.
Read string in file and place in array
<?php
$file = file_get_contents("filename.txt");
$data = preg_replace("/[^A-Za-z0-9 ]/", '', $file);
$result = preg_split("/[\s,]+/", $data);
echo $result[1];
echo $result[2];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment