Display Only First 5 Letters<

admin

Administrator
Staff member
Hi

I want to diplay only the first few letters of a word that is held in a mysql database.

At this time i have the line

$townname=$row_new["your_town"];

This will display the full town name, I want to be able to just display say the first 5 letters.

Thanks

Michael$townname=$row_new["your_town"];
$subtownname = substr($townname, 0, 5);

substr() gets a substring, as you can see in the name. It gets the substring of the string or variable in the first slot, the 0 above sets the starting point of where to start the substring, and the 5 represents how many characters from the string to take. More help in the link below.

<!-- m --><a class="postlink" href="http://us4.php.net/manual/en/function.substr.phpMany">http://us4.php.net/manual/en/function.substr.phpMany</a><!-- m --> thanks for that, so easy guess I should read more

Thanks

MichaelGlad I could help, that's a rarity for me here, helping and not being helped that is.
 
Back
Top