Why do I need to do array indexing using curly braces inside an if statement expression? Why is the following illegal?
$birthday = "1990-01-18";
$date_birth = explode("-", $birthday);
if ($date_birth[1] != "00" && $date_birth[2] != "00") {
$monthName = date('F', mktime(0, 0, 0, $date_birth[1], 10));
echo "$monthName $date_birth[2]";
}
However, the following works fine:
$birthday = "1990-01-18";
$date_birth = explode("-", $birthday);
if ($date_birth{1} != "00" && $date_birth{2} != "00") {
$monthName = date('F', mktime(0, 0, 0, $date_birth[1], 10));
echo "$monthName $date_birth[2]";
}