Learn How To Remove Letters From The beginning Of a String in PHP Function
RegisterLogin
Learn How To Remove Letters From The beginning Of a String in PHP Function
Post Description: Learn How To Remove Letters From The beginning Of a String in PHP Function
Tags: Learn, How, To, Remove, Letters, From, The, beginning, Of, a, String, in, PHP, Function
This Post Was Posted On Feb 29, 2008 By web hosting #1232
Post Description: Learn How To Remove Letters From The beginning Of a String in PHP Function
Tags: Learn, How, To, Remove, Letters, From, The, beginning, Of, a, String, in, PHP, Function
This Post Was Posted On Feb 29, 2008 By web hosting #1232
Learn How To Remove Letters From The beginning Of a String in PHP Function by web hosting
"How I learned somethign new at wallpaperama.com for me";
if you want to know how you can remove characters from the beginning of a string in php you can do it with the substr() funcion. lets say we have a string that its equal to "How I learned somethign new at wallpaperama.com for me"
so lets say i want to remove the first four letters (or characters) from my string so this is how i would get those letters out.
Code:
<?php
$string = "How I learned somethign new at wallpaperama.com for me";
$newstring = substr($string, 4);
echo $newstring;
?>
$string = "How I learned somethign new at wallpaperama.com for me";
$newstring = substr($string, 4);
echo $newstring;
?>
the output will look like this:
Code:
I learned somethign new at wallpaperama.com for me
Note that the number 4 means how many characters counting from the start of your string you are going to be removing. that's it, we are finish with this small simple tutorial step by step guide. hope you learned something new today about how to do programming in php to be able to get out the first (starting) letters or numbers from a sentence or a string in your scripts code. with this sample code you will be able to show or display you scipt when you open it with your browser on your webpage.
substr() is avaliable on PHP 4 and PHP 5
substr � Return part of a string
Description: string substr ( string $string, int $start [, int $length] )
substr() returns the portion of string specified by the start and length parameters.
If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.
if you want to learn more about the substr() function you can visist php.net
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2011 Webune Forums - Fri Dec 23, 2011 11:28 am
Powered by: Webune Forums V3
Powered by: Webune Forums V3