public function subwords($string, $offset)//{{{
{
/*
START CHECKING DATA...
*/
if (!is_int($offset)) die('Int expected '.gettype($offset).' given!');
if ($offset <= 0) die('The offset must be more than zero!');
if (!is_string($string) and !is_int($string)) die('String or integer expected '.gettype($string).' given!');
/*
...FINISH CHECKS DATA
*/
$times = 0;
for ($i=$offset, $k=0; $i<=strlen($string)-1; $i++, $k++)
{
if ($string{$offset+$k} == ' ')
{
$times++;
$find = ($offset + $k);
if ($offset == 0)
{
if ($times > $offset) break;
}
else
{
if ($times >= $offset) break;
}
}
}
$end_offset = $find;
return substr($string, 0, $end_offset);
}//}}}