Return to Snippet

Revision: 59194
at August 23, 2012 05:35 by Gianino


Updated Code
function short($txt,$size){
    
    $short = $size - 3;
    if(strlen($txt) > $size){
        $data = substr( $txt, 0, $short )."...";
    }
    else
    {
        $data = $txt;
    }

    return $data;
}


echo short('Gianino Cole',10);

Revision: 59193
at August 23, 2012 05:30 by Gianino


Initial Code
zxczxczxczxc

Initial URL


Initial Description
Reduces the string size according to the parameter that has been send and put '...' at the end of the new string

Initial Title
Shortening a string

Initial Tags
php

Initial Language
PHP