Return to Snippet

Revision: 17468
at September 6, 2009 14:14 by rupakdhiman


Initial Code
<?php
       //Storing a long string in a variable.
       $string = "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.";

       //Display the string in it's original format.
       echo $string;

       //Get the lenght of the string.
       $str_length = strlen($string);       
       echo "<br/>";
       
       //Method to chunk and replace a long string with some characters if you have space issues.
       if($str_length > 25)
       {
           //displayig the replaced string.
           echo substr($string, 0, 25) . "..." . "<br/>";//Replacing the string with Dots.
           echo substr($string, 0, 25) . "***" . "<br/>";//Replacing the string with Asteriks.
           echo substr($string, 0, 25) . ">>>" . "<br/>";//Replacing the string with Angular Brackets.
       }
       ?>

Initial URL


Initial Description


Initial Title
Replacing a long string with special characters like dots.

Initial Tags


Initial Language
PHP