Page is a not externally linkable
darrenG - 10:17 am on Jul 1, 2007 (gmt 0)
[opener][list of items].[result or outcome]. Then you could perform the following (not tested so might need tinkering): $str = 'You need to replace the carburetor, transmission, spark plugs, both driver and passenger mirrors, and tailights. This should come out to around $800.; //seperate sentences //seperate items //You now have: $len = count($items) - 1; for($i = 1; $i <= $len; $i++) { elseif($i == $len) { $string = $string.'.'.$sentences[1]; [1][edited by: darrenG at 10:45 am (utc) on July 1, 2007]
If you know that the string will always be in the format:
$sentences = explode('.', $str);
$items = explode(',', $sentences[0]);
//items[0] = 'You need to replace the carburetor';
//items= ' transmission';
//...and so on
$items[0] = substr($items[0], 0, strpos('the') + 4);
$items[] = substr($items[0], strpos('the') + 3);
$items[] = substr($items[$len], strpos('and') + 3);
$string = $items[0];
$items[0] = '';
shuffle($items);
if($i == $len - 1) {
$string .= $items[$i];
}
$string .= ' and'.$items[$i];
}
else
$string .= $items[$i].',';
}