/usr/share/php/PHP/Compat/Function/str_getcsv.php is in php-compat 1.6.0a3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <?php
/**
* Replace str_getcsv()
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2009 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
* @link http://php.net/function.str_getcsv
* @author HM2K <hm2k@php.net>
* @version $CVS: 1.0 $
* @since 5.3.0
* @require PHP 4.0.0 (fgetcsv)
*/
function php_compat_str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\') {
$fh = tmpfile();
fwrite($fh, $input);
$data = array();
while (($row = php_compat_fgetcsv_wrap($fh, 1000, $delimiter, $enclosure, $escape)) !== FALSE) {
$data[] = $row;
}
fclose($fh);
return empty($data) ? false : $data;
}
/**
* Wraps fgetcsv() for the correct PHP version
*
* @link http://php.net/function.fgetcsv
*/
function php_compat_fgetcsv_wrap($fh, $length, $delimiter = ',', $enclosure = '"', $escape = '\\') {
// The escape parameter was added
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
return fgetcsv($fh, $length, $delimiter, $enclosure, $escape);
}
// The enclosure parameter was added
elseif (version_compare(PHP_VERSION, '4.3.0', '>=')) {
return fgetcsv($fh, $length, $delimiter, $enclosure);
} else {
return fgetcsv($fh, $length, $delimiter);
}
}
if (!function_exists('str_getcsv')) {
/**
* Backwards compatbility for str_getcsv()
*
* @link http://php.net/function.fgetcsv
*/
function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\') {
return php_compat_str_getcsv($input, $delimiter, $enclosure, $escape);
}
}
|