note 103843 added to function.substr

From: Date: Fri, 06 May 2011 11:17:07 +0000
Subject: note 103843 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-179484@lists.php.net to get a copy of this message
If you need to parse utf-8 strings char by char, try this one: $utf8marker=chr(128); $count=0; while(isset($string{$count})){ if($string{$count}>=$utf8marker) { $parsechar=substr($string,$count,2); $count+=2; } else { $parsechar=$string{$count}; $count++; } /* do what you like with parsechar ... , eg.:*/ echo $parsechar."<BR>\r\n"; } - it works without mb_substr - it is fast, because it grabs characters based on indexes when possible and avoids any count and split functions ---- Server IP: 69.147.83.197 Probable Submitter: 92.201.170.160 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/103843 Del: integrated -- https://master.php.net/note/delete/103843/integrated Del: useless -- https://master.php.net/note/delete/103843/useless Del: bad code -- https://master.php.net/note/delete/103843/bad+code Del: spam -- https://master.php.net/note/delete/103843/spam Del: non-english -- https://master.php.net/note/delete/103843/non-english Del: in docs -- https://master.php.net/note/delete/103843/in+docs Del: other reasons-- https://master.php.net/note/delete/103843 Reject -- https://master.php.net/note/reject/103843 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179484) next »