note 89154 added to function.preg-match-all

From: Date: Tue, 24 Feb 2009 15:01:37 +0000
Subject: note 89154 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-151067@lists.php.net to get a copy of this message
chuckie's mb_preg_match_all() does not work if mbstring.func_overload is enabled for string functions. Here is the corrected version: <?php function mb_preg_match_all($ps_pattern, $ps_subject, &$pa_matches, $pn_flags = PREG_PATTERN_ORDER, $pn_offset = 0, $ps_encoding = NULL) { // WARNING! - All this function does is to correct offsets, nothing else: // if (is_null($ps_encoding)) $ps_encoding = mb_internal_encoding(); $pn_offset = mb_strlen(mb_substr($ps_subject, 0, $pn_offset, $ps_encoding), 'ISO-8859-1'); $ret = preg_match_all($ps_pattern, $ps_subject, $pa_matches, $pn_flags, $pn_offset); if ($ret && ($pn_flags & PREG_OFFSET_CAPTURE)) foreach ($pa_matches as &$ha_match) foreach ($ha_match as &$ha_match) $ha_match[1] = mb_strlen(mb_substr($ps_subject, 0, $ha_match[1], 'ISO-8859-1'), $ps_encoding); // // (code is independent of PREG_PATTER_ORDER / PREG_SET_ORDER) return $ret; } ?> ---- Server IP: 62.112.195.86 Probable Submitter: 88.209.232.203 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- https://master.php.net/note/edit/89154 Del: integrated -- https://master.php.net/note/delete/89154/integrated Del: useless -- https://master.php.net/note/delete/89154/useless Del: bad code -- https://master.php.net/note/delete/89154/bad+code Del: spam -- https://master.php.net/note/delete/89154/spam Del: non-english -- https://master.php.net/note/delete/89154/non-english Del: in docs -- https://master.php.net/note/delete/89154/in+docs Del: other reasons-- https://master.php.net/note/delete/89154 Reject -- https://master.php.net/note/reject/89154 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151067) next »