don't forget that inside your function the variable $text is something else than the global variable $text!
unfortunately you overwrite the input-variable in your function.
function myfunction($text) {
global $text,$topic;
// the variable $text from input gets overwritten by the global one
if ($text==$topic) {
print $topic;
} else {
print $text;
}
}
instead of this, you should try:
function myfunction($input) {
global $text, $topic;
($input == $topic) ? $foo = $input : $foo = $text;
print $foo;
}
//test:
myfunction($topic);
should work 🙂
greets
axo