note 70237 added to function.strcspn
| From: | PHPatNospamImmortalSoFardotcom at osu1 dot php dot net | Date: | Sun, 08 Oct 2006 01:31:23 +0000 |
| Subject: | note 70237 added to function.strcspn | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118197@lists.php.net to get a copy of this message | ||
Also useful for breaking down expressions - for example parsing SQL: values ('this',
fn("that,)()", 4))
$sep = strcspn ($list, "'\"`"); // Start of quoted string
$list = substr ($list, $sep);
$find = substr ($list, 0, 1);
while (($sep = strpos ($list, $find, $sep+1)) > 0 && substr ($list, $sep-1, 1) ==
'\\')
{}
// $sep now spans the entire string, regardless of embedded quotes
Once the strings have been removed, an expression can then be parsed for commas and brackets without
worrying about them:
while ($out != '')
{
$sep = strcspn ($list, "(),"); // Next seperator
...
}
----
Server IP: 64.71.164.2
Probable Submitter: 24.19.159.121
----
Manual Page -- http://www.php.net/manual/en/function.strcspn.php
Edit -- https://master.php.net/note/edit/70237
Del: integrated -- https://master.php.net/note/delete/70237/integrated
Del: useless -- https://master.php.net/note/delete/70237/useless
Del: bad code -- https://master.php.net/note/delete/70237/bad+code
Del: spam -- https://master.php.net/note/delete/70237/spam
Del: non-english -- https://master.php.net/note/delete/70237/non-english
Del: in docs -- https://master.php.net/note/delete/70237/in+docs
Del: other reasons-- https://master.php.net/note/delete/70237
Reject -- https://master.php.net/note/reject/70237
Search -- https://master.php.net/manage/user-notes.php