I have a function that get's a quick single item from a query:
function gimme($sql) {
global $mysqli;
global $mytable;
global $sid;
$query = "SELECT ".$sql." FROM ".$mytable." WHERE sid = ".$sid; $result = $mysqli->query($query);
$value = $result->fetch_array(MYSQLI_NUM);
$$sql = is_array($value) ? $value[0] : "";
return $$sql; // this is what I've tried so far
$result->close();
}
It works great as:
echo(gimme("name"));
Then I realized that I could use that as a variable ('$name' in this case) elsewhere. However, I can't figure out how get that new, variable variable 'outside' of the function. As such,
echo($name);
isn't working outside the function. Is there a way to return a variable variable? In other words, is there a way to make a function that creates a variable variable that will available outside of the function?
Thanks