note 44766 added to function.substr

From: Date: Mon, 16 Aug 2004 03:06:44 +0000
Subject: note 44766 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-74744@lists.php.net to get a copy of this message
The the following function posted by blackbunny: //if your string like "0000053004". you can use this function. this function erase "0" from your string start. function nozerofirst($string) { $dongu=strlen($string); for ($i=0; $i<$dongu; $i++) { $g=10-$i; $u=substr($string,$i,1); if ($u!=0) { $a= substr($string,$i,$g)."<br>"; break; } } return $a; } $string = "000101231"; echo nozerofirst($string); can simply be replaced by: $string = "000101231"; echo $string*=1; ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44766 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44766&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44766&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74744) next »