Usage is
truncate("$text", "#");
Example
$text = "I am browsing hotscripts.com";
truncate("$text", "10");
Would return
I am brows...
$text = "I am browsin";
truncate("$text", "10");
Would return
I am browsin
use
include("./path/to/function.truncate.php");
somewhere on your page.