Is there a way to dynamically create a variable name within the if condition ()s
In the example below, I want the '$variable' in the if statement to be replaced by $person1 the first iteration and $person2 the second iteration.
$person1 = "";
$person2 = "Joe";
for ($i = 1; $i <= 2; $i++) {
if ( $variable != "") {
print "Hello $i!";
}
}
So the end result would be that it would not execute the if commands the first time because $person1 == "", but on the second time it would execute the if commands because $person2 != "". Any ideas??
Thanks