I am trying to return a variable from a function and print it out. Its displaying unexpected T_STRING right now…. Can someone help?
function reg_word($i){
$reg_word = "/[^A-Za-z0-9 ]/";
$i = preg_replace($reg_word, '', $i);
}
$suggestion = function reg_word($_POST['suggestions']);
print_r($suggestion);
You had
functionkeyword beforereg_word($_POST['suggestions']);– you don’t need it.You need to use
returnkeyword to return something from a function.