note 100678 modified in function.substr by danbrown

From: Date: Sat, 30 Oct 2010 01:09:44 +0000
Subject: note 100678 modified in function.substr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173602@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 : <?php 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, --was-- 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, http://php.net/manual/en/function.substr.php

« previous php.notes (#173602) next »