Last active
October 13, 2015 17:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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