note 89762 added to function.substr

From: Date: Sun, 22 Mar 2009 01:52:40 +0000
Subject: note 89762 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-152273@lists.php.net to get a copy of this message
And as always there is bound to be a bug: <?php function strlen_entities($text) { preg_match_all( '/((?:&(?:#[0-9]{2,}|[a-z]{2,});)|(?:[^&])|'. '(?:&(?!\w;)))s',$text,$textarray); return count($textarray[0]); } function substr_entities($text,$start,$limit=0) { $return = ''; preg_match_all( '/((?:&(?:#[0-9]{2,}|[a-z]{2,});)|(?:[^&])|'. '(?:&(?!\w;)))s',$text,$textarray); $textarray = $textarray[0]; $numchars = count($textarray)-1; if ($start>=$numchars) return false; if ($start<0) { $start = ($numchars)+$start+1; } if ($start>=0) { if ($limit==0) { $end=$numchars; } elseif ($limit>0) { $end = $start+($limit-1); } else { $end = ($numchars)+$limit; } for ($i=$start;($i<=$end && isset($textarray[$i]));$i++) { $return .= $textarray[$i]; } return $return; } } ?> ---- Server IP: 83.137.20.135 Probable Submitter: 84.25.235.231 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/89762 Del: integrated -- https://master.php.net/note/delete/89762/integrated Del: useless -- https://master.php.net/note/delete/89762/useless Del: bad code -- https://master.php.net/note/delete/89762/bad+code Del: spam -- https://master.php.net/note/delete/89762/spam Del: non-english -- https://master.php.net/note/delete/89762/non-english Del: in docs -- https://master.php.net/note/delete/89762/in+docs Del: other reasons-- https://master.php.net/note/delete/89762 Reject -- https://master.php.net/note/reject/89762 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152273) next »