Have 2 methods to do it.
Method 1:
echo eval('return $'. $string . ';');
And another method as below:
$counter = 1; $button1 = "Hello PHP"; $printbutton = ${'button' . $counter}; echo $printbuttonThe Method 2 example will print out Hello PHP
echo eval('return $'. $string . ';');
$counter = 1; $button1 = "Hello PHP"; $printbutton = ${'button' . $counter}; echo $printbuttonThe Method 2 example will print out Hello PHP
You must be logged in to post a comment.