SHARE
TWEET

Untitled

a guest Jun 16th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cortarFrase($texto, $maxPalabras = 280, $noTerminales = ["de"]) {
  2.   $frase = explode(" ", $texto);
  3.   $numPalabras = count($frase);
  4.   if ($numPalabras > $maxPalabras) {
  5.      $offset = $maxPalabras - 1;
  6.      while (in_array($palabras[$offset], $noTerminales) && $offset < $numPalabras) { $offset++; }
  7.      return implode(" ", array_slice($frase, 0, $offset + 1));
  8.   }
  9.   return $frase;
  10. }
  11.      
  12. $texto: el texto a recortar
  13. $maxPalabras: el número de palabras que contendrá la frase (280 = a un tweet).
  14. $noTerminales: una lista de las palabras con las que no debe terminar el recorte. Parámetro opcional con valor inicial ["de"]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top