- Forums
- PHP
- How To Display Show The Last Characters In A String PHP
This Page Contains information about How To Display Show The Last Characters In A String PHP By wallpaperama in category PHP with 0 Replies. [1055], Last Updated: Sat May 18, 2024
wallpaperama
Thu Jul 12, 2007
0 Comments
779 Visits
supposed i hava a string and the the value ot the string is:
i love wallpaperama.com even moreso 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.comhere'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