View: Acortar texto con php

  1. 10 months ago by jacinmontava
    1. function acortar($texto,$longitud)
    2. {
    3.    $texto_partido = substr($texto,0,$longitud);
    4.  
    5.    /// Condición que comprueba la longitud del texto para devolverlo con ... o entero
    6.    if (strlen($texto) > $longitud)
    7.       return $texto_partido."...";
    8.    else
    9.       return $texto
    10. }

1 comment about "Acortar texto con php"

  1. He mejorado la function en el siguiente post:

    http://www.posteet.com/view/642

    Espero les sirva de mucho.

    Saludos regoremor
    regoremor on January 01, 2008