I have the following function below, and when I call the function it won't return any values, however if I put an echo inside the function (right before the return call) then it will show the values, but I cannot get those values outside the function with the function call. Anyone know why this is? Function and call is below. Thanks!
//Automatically finds words that are in the dictionary and replaces them with links in the form input
function DictEncode($forminput){
//Take form input and convert it into an array of words
$formwords = preg_replace("/[[:alnum:]|[:space:]]/","",$forminput);
$wordarray = explode(" ",$formwords);
//Connect to database and find words in the dictionary that match words in the above array
$db=mysql_connect("localhost","name","pass");
mysql_select_db("database",$db);
$query = "SELECT * FROM dict WHERE word IN ('".implode("', '", $wordarray)."');";
$myresult = mysql_query($query);
//Go through the results of the word matching and change the word into a link and resave it as the new form input
while ($row = mysql_fetch_array($myresult)) {
$origword = " ".$row["word"]." ";
$theword = "/".$row["word"]."/";
$worddef = $row["definition"];
$caption = "Definition: ".$origword."";
$replace = "<a href='javascript:void(0);' onMouseOver='overlib(\"".$worddef."\", CAPTION,\"".$caption."\")' onMouseOut='nd()'>".$origword."</a>";
$forminput = preg_replace($theword, $replace, $forminput);
}
echo $forminput;
return $forminput;
}
//End of function that automatically checks and adds links for Dictionary definitions that are in articles
//Call the Dictionary Encode function
$NewsMsg = DictEncode($NewsMsg);