Not sure how to name this question but I am looking for feedback to why when I set a variable to some string it will not let me call that variable in a function... For example:
$name = "name";
$quote_name = "'".$name."'";
//echo of $name = name
//echo of $quote_name = 'name'
PHP will not allow me to call:
if($value['name'] == $quote_name){...}
Or
if($value['name'] == '$name'){...}
But it WILL allow me to call (with the whole function):
foreach($question_set_p1 as $key => $value) {
if($value['name'] == 'name') {
$first = $key;
break;
}
}
$data = array_filter($question_set_p1, function($arr){
return $arr['name'] == 'name';
});
Why does PHP allow me to call the string but not the variable? Is there a way that I can state the variable and not the actual string?