I have this script on my site that suggests properly spelled words if a person searches by a misspelled word.
The spelling suggestions are contained in a variable which is defined by the PHP script segment at the bottom of this post.
Right now the output looks like this : “flood, flowood”, but with the rest of the script it reads like this: “Found 0 definitions found for floood. May we suggest: flood, flowood”.
Is there a way, and if yes, what would I do to replace the last comma in my string with “or”, so I would get “flood or flowood”?
Thanks
[code=php] // here we build the suggestions output
$terms=array();
$out=”;
foreach($res as $entry) {
if($entry) {
$match = explode(” “,rtrim($entry));
$terms[] = strtolower(str_replace(“””, “”, $match[1]));
}
}
function phoebe_suggestionLink($term) {
return “<a href=”$_SERVER[$PHP_SELF]?w=”.urlencode($term)
. ‘”>’.htmlentities($term).'</a>’;
}
if($terms) {
sort($terms);
$terms=array_map(‘phoebe_suggestionLink’,array_unique($terms));
$out=join(‘, ‘,$terms);
}
}
}
return $out;
}