Skip to content

Instantly share code, notes, and snippets.

@matiit
Last active October 13, 2015 17:38
Show Gist options
  • Save matiit/4232324 to your computer and use it in GitHub Desktop.
Save matiit/4232324 to your computer and use it in GitHub Desktop.
Checking for file existance, now code is running on older PHP versions too
/*
* loadSimpleFileToArray
*
* what the function does
*
* @param (String) path to the source file
* @return (Array)
*/
function loadSimpleFileToArray($fileName)
{
if (!file_exists($fileName))
{
return array();
}
$f = fopen($fileName,'r');
$records = [];
while(!feof($f))
$records[] = fgets($f);
return $records
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment