PHP variable value from string

eval, php, string, variables

Solution

Use curly braces to denote a variable:

$Member_Student        = 3600;
$selectedItem = "Member_Student";
$price = ${$selectedItem};
print_r($price); // prints 3600

Problem

How can I get value from variable which is string ? ``` $Member_Student = 3600; $selectedItem = "Member_Student"; $price = "$" . $selectedItem; print_r($price); //prints $Member_Student instead of 3600 ``` I cannot use eval function.

Original source