note 78819 added to function.array-slice
| From: | slimjackson at gmail dot com | Date: | Mon, 29 Oct 2007 18:06:01 +0000 |
| Subject: | note 78819 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131814@lists.php.net to get a copy of this message | ||
Re: 'cpa at NOSPAM dot conceptivator dot com' and 'gportlock at gembiz dot co dot
uk'
limitText can be further simplified by adding a limit parameter to the explode function -
eliminating the need for the use of array_slice entirely. Note that this only works for extracting
the first n words of the string, and not the last.
Also, you've mistakenly used array_splice instead of array_slice in your functions.
<?php
function limitText( $text, $wordCount )
{
$wordArray = explode(" ", $text, $wordCount);
return implode( " ", $wordArray );
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 216.96.169.143
----
Manual Page -- http://www.php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/78819
Del: integrated -- https://master.php.net/note/delete/78819/integrated
Del: useless -- https://master.php.net/note/delete/78819/useless
Del: bad code -- https://master.php.net/note/delete/78819/bad+code
Del: spam -- https://master.php.net/note/delete/78819/spam
Del: non-english -- https://master.php.net/note/delete/78819/non-english
Del: in docs -- https://master.php.net/note/delete/78819/in+docs
Del: other reasons-- https://master.php.net/note/delete/78819
Reject -- https://master.php.net/note/reject/78819
Search -- https://master.php.net/manage/user-notes.php