Better Truncator

<?php

$longString ="http://google-maps.pace.com?var=ntahohk5eoui564x56oe4u564oa5oeu5aoeu5ao5u5eu56io14eui564oe";
$separator = '/.../';
$separatorlength = strlen($separator) ;
$maxlength = 25 - $separatorlength;
$start = $maxlength / 2 ;//Change to max length to truncate end
$trunc = strlen($longString) - $maxlength;

echo substr_replace($longString, $separator, $start, $trunc);

?>

0 Comments

You must be logged in to post a comment.