I'm a novice at php, and the upshot is that I am trying to have the character "$" treated as a variable designator for a variable defined by a combination of strings.
I am trying to generate a dynamic variable that will integrate a url-passed variable and into a new variable. In the example below, the url-passed variable ($url_var) will be numeric (1, 2, 3, etc.). This variable has been defined in php with $_REQUEST. Then I want to combine this variable with character strings to define a new variable ($title) that is dynamic and depends on the value of $url_var. There are multiple "titles" that are relevant (e.g., $pub1_title, $pub2_title), that related directly to $url_var. That is, $pub1_title would be relevant when $url_var = 1, and so on. So I can simply define $title for each case (e.g, $title=$pub1_title when $url_var =1), but I'd like to have a single dynamic line of code. To do this, I need to have the character "$" interpreted as a variable designator. Quite simply, how do I do this? And, is there a more efficient way to do this?
<?
// Define Pub Variables
$url_var = $_REQUEST['url_var'];
$pub1_title = "pub1_title";
$pub2_title = "pub2_title";
// Make Title Variable
$title = "$" . "pub" . $url_var . "_title"; // Does not work (returns "$pub1_title")
//$title = $pub1_title; // This works, but is static.
echo $title;
?>