note 54089 deleted from function.explode by bjori
| From: | bjori@php.net | Date: | Mon, 25 Sep 2006 08:09:20 +0000 |
| Subject: | note 54089 deleted from function.explode by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117584@lists.php.net to get a copy of this message | ||
Note Submitter: hardy at mapscene dot de
----
here are some usefully simple functions to get word-parts of an given string... i remember to that
functions by using arexx on amiga :)
function words($string,$seperator=" ") {//amount of words in the string
$array = explode($seperator, $string);
return count($array);
}
function word($string,$number=1,$seperator=" ") {//word num of string
if($number>0)$number--;
$array = explode($seperator, $string);
if(count($array)>=$number)
return $array[$number];
return;
}
function lastword($string,$seperator=" ") {//last word of an string
$array = explode($seperator, $string);
$number = count($array);
if($number>0) {
$number--;
return $array[$number];
}
return;
}