note 97011 added to function.gzfile
| From: | allankellyATgmailDOTcom at osu1 dot php dot net | Date: | Sun, 28 Mar 2010 13:55:45 +0000 |
| Subject: | note 97011 added to function.gzfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167458@lists.php.net to get a copy of this message | ||
<?php
##################################
# function file_as_array( $fname )
# open gz or plaintext files
function file_as_array( $fname )
{
##################################################
# load file - try .gz first because it's preferred
$a_entries = array();
if( preg_match( '/\.gz$/', $fname ) )
{
$gzfname = $fname;
}
else
{
$gzfname = $fname.".gz";
}
if( file_exists( $gzfname ) )
{
# Try for a .gz file
$a_entries = gzfile( $gzfname );
# gzfile has no FILE_IGNORE_NEW_LINES, so trim to remove newlines.
for( $i=0; $i<sizeof($a_entries); $i++ )
{
$a_entries[$i] = trim($a_entries[$i]);
}
}
else if( file_exists( $fname ) )
{
$a_entries = file( $fname, FILE_IGNORE_NEW_LINES );
}
return $a_entries;
} # END function file_as_array( $fname )
?>
----
Server IP: 69.147.83.197
Probable Submitter: 78.149.89.110
----
Manual Page -- http://www.php.net/manual/en/function.gzfile.php
Edit -- https://master.php.net/note/edit/97011
Del: integrated -- https://master.php.net/note/delete/97011/integrated
Del: useless -- https://master.php.net/note/delete/97011/useless
Del: bad code -- https://master.php.net/note/delete/97011/bad+code
Del: spam -- https://master.php.net/note/delete/97011/spam
Del: non-english -- https://master.php.net/note/delete/97011/non-english
Del: in docs -- https://master.php.net/note/delete/97011/in+docs
Del: other reasons-- https://master.php.net/note/delete/97011
Reject -- https://master.php.net/note/reject/97011
Search -- https://master.php.net/manage/user-notes.php