how to display show the last characters in a string PHP

RegisterLogin
how to display show the last characters in a string PHP
Post Description: how to display show the last characters in a string PHP
Tags: how, to, display, show, the, last, characters, in, a, string, PHP
This Post Was Posted On Feb 29, 2008 By web hosting #1267
supposed i hava a string and the the value ot the string is: i love wallpaperama.com even more
so this is how the PHP would look like so far:
$string = 'i love wallpaperama.com even more';


now, lets say i don't want the ten characters ( even more) to show i only want i love wallpaperama.com. so if want to erase the part that says ' even more' this is how my code would look like so far:
$string = 'i love wallpaperama.com even more';
$string = substr($string, 0,23);

What the substr() function tells php is that to on get the first first 23 charracters starting a 0, therefore, removing the last 10 characters, so if i were to echo $string, the value would come out like this i love wallpaperama.com

here's the complete script:
<?
$string = 'i love wallpaperama.com even more';
$string = substr($string, 0,23);
echo string;
?>


OUTPUT:
i love wallpaperama.com



COURTESY: thanks to the webune.com team for their help on this. Find PHP hosting and more scripts at www.webune.com

NEXT: how to display the last characters of a string in PHP

Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2011 Webune Forums - Wed Dec 21, 2011 7:45 pm
Powered by: Webune Forums V3