note 87197 added to reference.pcre.pattern.syntax

From: Date: Mon, 24 Nov 2008 09:18:55 +0000
Subject: note 87197 added to reference.pcre.pattern.syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-146854@lists.php.net to get a copy of this message
Hi! For even better prestanda of the code below, use; <?php $f = array(); foreach($allTags[1] as $tag){ $f[] = "%(<$tag.*?>)(.*?)(<\/$tag.*?>)%is"; } if(sizeof($f)) $str = preg_replace($f, ($stripContent ? '' : '${2}'), $str); ?> This will not use preg_replace on every tag, instead it collect the regex as array, and then executes and should be better. It also check so there are any regex to replace! If not, it will not start preg_replace! :) Added the "<?php" so it will highlight the code! ---- Server IP: 80.67.2.2 Probable Submitter: 194.116.156.241 ---- Manual Page -- http://www.php.net/manual/en/reference.pcre.pattern.syntax.php Edit -- https://master.php.net/note/edit/87197 Del: integrated -- https://master.php.net/note/delete/87197/integrated Del: useless -- https://master.php.net/note/delete/87197/useless Del: bad code -- https://master.php.net/note/delete/87197/bad+code Del: spam -- https://master.php.net/note/delete/87197/spam Del: non-english -- https://master.php.net/note/delete/87197/non-english Del: in docs -- https://master.php.net/note/delete/87197/in+docs Del: other reasons-- https://master.php.net/note/delete/87197 Reject -- https://master.php.net/note/reject/87197 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146854) next »