I have a variable variable defined, suppose:
$array[1] = Hello World;
$i = 1;
${"name" . $i} = $array[1];
I then have the following:
$val1 = "Hello World";
However when I try to compare $name1 to $val1, they are never equal.
I've tried all of the following:
if ($name1 == $val1){
echo 'yes';
}
else{
echo 'no';
}
//second try
if ($name1 === $val1){
echo 'yes';
}
else{
echo 'no';
}
//3'rd attempt
if((string)$name1 === $val1){
echo 'yes';
}
else{
echo 'no';
}
All print out no
Any ideas?