You are on page 1of 2

How to replace the long text with dots

In php we can easily replace the long text with the dots.

Here we use the substr function in PHP.

The below example shows the program for that….

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?
$message="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

if(strlen($message)>15)
{

$listedword=substr($message,0,15);
echo $listedword."...";
}
else
{
echo $message;
}
?>
</body>
</html>

The output is

ABCDEFGHIJKLMNO...

The first fifteen letters are printed and the remaining with dots…

For more information visit

http://php.net/manual/en/function.substr.php
Please visit

http://technotiger87.blogspot.com

Leave the comments to improve us..

You might also like