note 71983 added to function.preg-match-all

From: Date: Wed, 27 Dec 2006 21:07:36 +0000
Subject: note 71983 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-120963@lists.php.net to get a copy of this message
This function is useful to parse search queries with escaped quotes <?php print_r(parse_words('some text "quoted text" other text')); function parse_words($text, $minlength = 3) { $result = Array(); if(@preg_match_all('/"(?P<string>[^"\\\\]{' . $minlength . ',}(?:\\\\.[^"\\\\]*)*)"|(?P<words>[^ "]{' . $minlength . ',})/', $text, $regs)) { if(($result = @array_unique(@array_filter($regs['words']) + @array_filter($regs['string']))) !== NULL) { @ksort($result, SORT_NUMERIC); }; }; return($result); }; ?> result: Array ( [0] => some [1] => text [2] => quoted text [3] => other ) ---- Server IP: 212.124.37.9 Probable Submitter: 84.140.112.194 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- https://master.php.net/note/edit/71983 Del: integrated -- https://master.php.net/note/delete/71983/integrated Del: useless -- https://master.php.net/note/delete/71983/useless Del: bad code -- https://master.php.net/note/delete/71983/bad+code Del: spam -- https://master.php.net/note/delete/71983/spam Del: non-english -- https://master.php.net/note/delete/71983/non-english Del: in docs -- https://master.php.net/note/delete/71983/in+docs Del: other reasons-- https://master.php.net/note/delete/71983 Reject -- https://master.php.net/note/reject/71983 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120963) next »