How can the code be improved to correctly output the gender based on the value in the array?

The issue in the code is that the comparison operator is using a single equal sign (=) instead of a double equal sign (==). The single equal sign is used for assignment, while the double equal sign is used for comparison. To correctly output the gender based on the value in the array, we need to change the single equal sign to a double equal sign in the if statement.

<?php

$gender = "male";
$genderArray = array("male", "female");

if ($gender == $genderArray[0]) {
    echo "Gender is male";
} elseif ($gender == $genderArray[1]) {
    echo "Gender is female";
} else {
    echo "Gender is not specified";
}

?>