Page 1 of 1

only print 8 characters

Posted: Tue Oct 14, 2008 4:21 am
by swamyt
Hello,

I want to print only 8 characters then after print three dots using string functions

So please help me

Thanks And Regards
swamy

Re: only print 8 characters

Posted: Tue Oct 14, 2008 4:51 am
by Kadanis

Code: Select all

 
<?php
 
$originalString = 'Hello World!';
 
$newString = substr($originalString, 0, 8) . '&hellip;';
 
//output is Hello Wo...
echo $newString;
?>
 
Edit: fixed, thanks onion ;)

Re: only print 8 characters

Posted: Tue Oct 14, 2008 5:04 am
by onion2k
Instead of ... as dots you really ought to be using &hellip;