how to limit characters in a string in php

RegisterLogin
how to limit characters in a string in php
Post Description: how to limit characters in a string in php
Tags: how, to, limit, characters, in, a, string, in, php
This Post Was Posted On Feb 29, 2008 By questions #847
hi, im fairly new to php, and i was wondering if its possible to limit the numbers of letter or numbers (characters) in a string. for example, i have this sample code string:

$string = "i have alot of words here and want to make it shorter";

ok, lets say i only want to show the first 15 characters from this string, how would i do that?
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
rob
#1097 1
20080228-43530-zzy1p89tgzw1jwo
yes, this is very helpful.
Feb 28, 2008 Reply Report abuse
Webune
#1096 2
you would do it like this:

echo substr($string, 0,15);


the output will display something like this:

OUTPUT:
i have alot of


hope this help? if you ever need php web hosting, the best you can find is at www.webune.com

Webune.com has the best php webhoting anywhere. i recommend them to all my customers, they have great support also. i should know, because i am answering this question to you on behalf of Webune.
Jun 25, 2007 Reply Report abuse
©2011 Webune Forums - Sat Dec 24, 2011 8:49 pm
Powered by: Webune Forums V3