note 70237 deleted from function.strcspn by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 14:59:22 +0000 |
| Subject: | note 70237 deleted from function.strcspn by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197275@lists.php.net to get a copy of this message | ||
Note Submitter: PHP at NospamImmortalSoFar dot com
----
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
...
}