Very short snippet: PHP word cut
Sunday, September 21, 2008Delimits a portion of text to the number of "words":
- / **
- * String word cut
- *
- * @ Private
- * /
- $c , $l ) { wordCut function ($ c, $ l) (
- $i = 0 ; $i < $l ; $i ++ ) $r [ $i ] = $c [ $i ] ; for ($ i = 0; $ i <$ l, $ i + +) $ r [$ i] = $ c [$ i];
- ; return $ r;
- )













From 2 rows for a esempiuccio you could ask.
My tagliaStringa ($ string, $ numParole) is a bit 'different ... Not use two arrays, but builds the string by inserting the words as a variable, then cutting off the last space and adding three dots ...
What?
Thank you! Carpita and used ...
LOL!
@ Tom: Oh, an example for a function "cut the strings" is a bit 'too ...
However, for example, you can use to:
'll Get in
$resSample string long enough ...@ Napolux: I searched in vain for your role on your blog ... cmq even so would be fine:
Note the "treat" for not trying to eliminate the extra space
@ Julius: Please dear! Although no one has noticed that for large strings to its proper function would be:
Je n'en dirai pas plus:
http://fr.php.net/manual/fr/function.substr.php
et pour finir an example:
http://www.destrucsaweb.com/ressources/phpmyannu/goto_38.php
A +
[...] Already seen Very short snippet: PHP word cut is more pleasant to break a text to "words", because it avoids cutting a word. There [...]