note 100678 added to function.substr
| From: | Cristianlf at osu1 dot php dot net | Date: | Fri, 29 Oct 2010 21:10:32 +0000 |
| Subject: | note 100678 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173600@lists.php.net to get a copy of this message | ||
I needed a function like lpad from oracle, or right from SQL
then I use this code :
<?
function right($string,$chars)
{
$vright = substr($string, strlen($string)-$chars,$chars);
return $vright;
}
echo right('0r0j4152',4);
?>
Result:
4152
------------------------------------------------
This function is really simple, I just wanted to share, maybe helps someone out there.
regards,
----
Server IP: 69.147.83.197
Probable Submitter: 190.56.162.142
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/100678
Del: integrated -- https://master.php.net/note/delete/100678/integrated
Del: useless -- https://master.php.net/note/delete/100678/useless
Del: bad code -- https://master.php.net/note/delete/100678/bad+code
Del: spam -- https://master.php.net/note/delete/100678/spam
Del: non-english -- https://master.php.net/note/delete/100678/non-english
Del: in docs -- https://master.php.net/note/delete/100678/in+docs
Del: other reasons-- https://master.php.net/note/delete/100678
Reject -- https://master.php.net/note/reject/100678
Search -- https://master.php.net/manage/user-notes.php