On a simple foreach loop that is generating variables variables, how can I add an underscore after the $ in the variable? The variable names are coming from the names of the columns in a table and are being populated by the single entry being fetched.
// Fetch values
$sqlVal = "SELECT *
FROM tablename
WHERE ID=$PostID";
$rowVal = DBConnect($sqlVal, "Select", $siteDB);
// Create variable variables from table column names and populate with value
foreach ($rowRow as $val=>$resultVal) :
if (is_string($val)) :
$$val = $resultVal;
endif;
endforeach;
echo "test: $ValName";
The test result above works but I want it to be $_ValName with the underscore but I can't seem to work out how to achieve that.