Forums »
  PHP Forums And Topics Discussions About Hyper Text Programming Language »
    Limit The Number Of Characters In A String Variable

Limit The Number Of Characters In A String Variable

Description: use this howto tutorial will show you how you can limit the number of characters in a string to be displayed
Tags: php ,code ,function ,snippet
Posted On Fri Sep 09, 2011 By hostman In PHP Forums And Topics Discussions About Hyper Text Programming Language Forums
today we received a question we often get regarding creating code for a wallpaper website using PHP. this is the question

question: i am doing some work for a wallpaper website and i need to display some text into a form but some of these field values are too long, i want to limit the value of a string to only a certain amount of character

answer: you can use the substr() in PHP to limit the amount of characters is displayed on your webpage.

example, $foo is 500 characters long, i want to show only the first 30 letters:

<?php
$foo = 'Wallpaperama is a great source for help on your wallpaper website';
$foo = substr($foo, 0,30);
echo $foo;
?>


OUTPUT:
Wallpaperama is a great source


hope that helps anyone
Information
Title: Limit The Number Of Characters In A String Variable
Info: This Post Has Been Viewed 0 Times Since
Date: Fri Sep 09, 2011
Author hostman Received 0 Replies #1301
Related Sites
Add Your Website
Share
wallpaperama | Wallpapers | Forums | Terms Of Service

copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Wed Jun 19, 2013 (-8 GMT)
Powered by: Webune Forums V5