Extract word from a string given a position in php
function extractWord($text, $position){
$words = explode(' ', $text);
$characters = -1;
foreach($words as $word){
$characters += strlen($word);
if($characters >= $position){
return $word;
}
}
return '';
}