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