I basically want a way to write an if statement with only one variable in it, like:
$var = "$foo == 'bar'"; if ($var) { // do code } Or to put it more descriptively, Instead of:
$run_list = array("normal"); if (!empty("extras")) array_push($run_list, "extras"); foreach ($run_list as $iteration) { if ($iteration == "normal") { if ($array1 == $array2) { # do 125 lines of code here } // Will not always be True (may only iterate once) } elseif ($iteration == "extras") { if ($array1 != $array2) { # do exact same 125 lines of code here } } } How could I do something similar to this, but that actually works:
$run_list = array("normal"); if (!empty("extras")) array_push($run_list, "extras"); foreach ($run_list as $iteration) { if ($iteration = "normal") { $if_statement = "$array1 == $array2"; } elseif ($iteration = "extras") { $if_statement = "$array1 != $array2"; } if ($if_statement) { # do 125 lines of code here } } And I don't want to put the 125 lines of code into a function because they contain dozens of variables set earlier in the code and I don't really want to create a function where I have to pass in dozens of variables for it to work.
if($iteration == "normal")why do you want to change that into something complicated?