note 81842 added to function.sscanf
| From: | mikewillitsgmail dot com at osu1 dot php dot net | Date: | Sat, 15 Mar 2008 19:13:03 +0000 |
| Subject: | note 81842 added to function.sscanf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137089@lists.php.net to get a copy of this message | ||
FYI - if you are trying to scan from a string which contains a filename with extension. For
instance:
<?php
$out = sscanf('file_name.gif', 'file_%s.%s', $fpart1, $fpart2);
?>
The scanned string in the $fpart1 parameter turns out to be 'name.gif' and $fpart2 will be
NULL.
To get around this you can simply replace the "." with a space or another
"white-space like" string sequence.
I didn't see any other comments on regarding string literals which contain a '.' so I
thought I'd mention it. The subtle characteristics of having "white-space delimited"
content I think can be a source of usage contention. Obviously, another way to go is regular
expressions in this instance, but for newer users this may be helpful.
Just in case someone else spent 10 minutes of frustration like I did. This was seen on PHP Version
5.2.3-1ubuntu6.3.
Searching the bug reports shows another users misunderstanding: http://bugs.php.net/bug.php?id=7793
----
Server IP: 69.147.83.197
Probable Submitter: 76.238.8.181
----
Manual Page -- http://www.php.net/manual/en/function.sscanf.php
Edit -- https://master.php.net/note/edit/81842
Del: integrated -- https://master.php.net/note/delete/81842/integrated
Del: useless -- https://master.php.net/note/delete/81842/useless
Del: bad code -- https://master.php.net/note/delete/81842/bad+code
Del: spam -- https://master.php.net/note/delete/81842/spam
Del: non-english -- https://master.php.net/note/delete/81842/non-english
Del: in docs -- https://master.php.net/note/delete/81842/in+docs
Del: other reasons-- https://master.php.net/note/delete/81842
Reject -- https://master.php.net/note/reject/81842
Search -- https://master.php.net/manage/user-notes.php