note 42258 deleted from function.substr by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 10 May 2004 06:02:01 +0000 |
| Subject: | note 42258 deleted from function.substr by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69397@lists.php.net to get a copy of this message | ||
Note Submitter: don@onlygeeks.com
----
<?php
$astring = "testing the word limit. There should only be words here, and nothing too long.
:)";
$anumwords = 10;
function strwrd($string, $numwords)
{
// Blow up the string
$strings = explode(" ", $string);
// Make string for return
$string = "";
for($i = 0; $i < $numwords; $i++)
{
if($i > 0)
{
$string .= " ";
}
$string .= $strings[$i];
}
// Return the string
return $string;
}
// Test the new function
echo strwrd($astring, $anumwords); // returns: testing the word limit. There should only be words
here,
?>
Still needs to have the ability to ignore <> tags.