note 68181 added to function.preg-match-all

From: Date: Mon, 17 Jul 2006 14:11:59 +0000
Subject: note 68181 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-114844@lists.php.net to get a copy of this message
I refurnished connum at DONOTSPAMME dot googlemail dot com autoCloseTags function: <?php /** * close all open xhtml tags at the end of the string * * @author Milian Wolff <http://milianw.de> * @param string $html * @return string */ function closetags($html){ #put all opened tags into an array preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result); $openedtags=$result[1]; #put all closed tags into an array preg_match_all("#</([a-z]+)>#iU",$html,$result); $closedtags=$result[1]; $len_opened = count($openedtags); # all tags are closed if(count($closedtags) == $len_opened){ return $html; } $openedtags = array_reverse($openedtags); # close tags for($i=0;$i<$len_opened;$i++) { if (!in_array($openedtags[$i],$closedtags)){ $html .= '</'.$openedtags[$i].'>'; } else { unset($closedtags[array_search($openedtags[$i],$closedtags)]); } } return $html; } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 84.190.136.63 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- http://master.php.net/note/edit/68181 Del: integrated -- http://master.php.net/note/delete/68181/integrated Del: useless -- http://master.php.net/note/delete/68181/useless Del: bad code -- http://master.php.net/note/delete/68181/bad+code Del: spam -- http://master.php.net/note/delete/68181/spam Del: non-english -- http://master.php.net/note/delete/68181/non-english Del: in docs -- http://master.php.net/note/delete/68181/in+docs Del: other reasons-- http://master.php.net/note/delete/68181 Reject -- http://master.php.net/note/reject/68181 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114844) next »