note 106674 added to function.str-getcsv
| From: | xoneca at gmail dot com | Date: | Sun, 27 Nov 2011 12:26:03 +0000 |
| Subject: | note 106674 added to function.str-getcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184689@lists.php.net to get a copy of this message | ||
Note that this function can also be used to parse other types of constructions. For example, I have
used to parse .htaccess AddDescription lines:
AddDescription "My description to the file." filename.jpg
Those lines can be parsed like this:
<?php
$line = 'AddDescription "My description to the file." filename.jpg';
$parsed = str_getcsv(
$line, # Input line
' ', # Delimiter
'"', # Enclosure
'\\' # Escape char
);
var_dump( $parsed );
?>
The output:
array(3) {
[0]=>
string(14) "AddDescription"
[1]=>
string(27) "My description to the file."
[2]=>
string(12) "filename.jpg"
}
----
Server IP: 80.64.47.13
Probable Submitter: 89.7.255.87
----
Manual Page -- http://www.php.net/manual/en/function.str-getcsv.php
Edit -- https://master.php.net/note/edit/106674
Del: integrated -- https://master.php.net/note/delete/106674/integrated
Del: useless -- https://master.php.net/note/delete/106674/useless
Del: bad code -- https://master.php.net/note/delete/106674/bad+code
Del: spam -- https://master.php.net/note/delete/106674/spam
Del: non-english -- https://master.php.net/note/delete/106674/non-english
Del: in docs -- https://master.php.net/note/delete/106674/in+docs
Del: other reasons-- https://master.php.net/note/delete/106674
Reject -- https://master.php.net/note/reject/106674
Search -- https://master.php.net/manage/user-notes.php