How To Limit Characters In A String In Php

Mobile
feeds
Welcome Login | Register

How To Limit Characters In A String In Php
  Forums Index
      » Linux Hosting Forums
        » » how to limit characters in a string in php



How To Limit Characters In A String In Php
Post Description:
Post Tags: how, to, limit, characters, in, a, string, in, php, linux hosting, troubleshoot, help, support advise, questions, answers
This Post Has Been Viewed 333 Times Since Mon Jun 25, 2007 5:09 pm Posted By questions with 2 replies
How To Limit Characters In A String In Php
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






Share
URL:
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites



Fourms BBCODE:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums





Comments and replies About How To Limit Characters In A String In Php




:: 1 :: Reply #8202 Reply By Webune On Mon Jun 25, 2007 5:12 pm
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.
:: 2 :: Reply #43530 Reply By rob On Thu Feb 28, 2008 5:58 pm
20080228-43530-zzy1p89tgzw1jwo
yes, this is very helpful.