如何检查数组的值是否等于另一个数组的值,并在选择下拉列表中显示所选的值

I have two arrays one has list of all majors and other has list of majors of the selected project , the data is fetched form the database. I want to loop through the list of majors array and if its includes any of the project majors, i want to display it as selected in select drop down.

i have tried using nested while loop for iterating through both array, it but only displays one major instead of two

$majorList = $majorObject->getICTProjectMajor(); // row[0]

$assignedMajor = $projectMajorObject->getProjectMajor(28); //row[0]
if ($assignedMajor != false) {
    while ($assignedMajorRow = mysqli_fetch_array($assignedMajor)) {
        while ($row = mysqli_fetch_array($majorList)) {


            echo "<option value='$row[0]'";
            foreach ($assignedMajorRow as $majorID) {
                if ($majorID == $row[0]) {
                    echo " selected";
                }
                echo ">$row[1]</option>'";
            }


            echo "</select>";

        }
        echo "</select>";

    }

}

functions

public function getProjectMajor($projectID)
{

    if ($this->dbc != NULL) {
        $selectQuery = "SELECT Major.majorID FROM ProjectMajor JOIN Major on Major.majorID= ProjectMajor.majorID where projectID=$projectID";
        $selectResult = mysqli_query($this->dbc, $selectQuery);
        if ($selectResult != FALSE) {
            return $selectResult;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

public function getICTProjectMajor()
{
    if ($this->dbc != NULL) {
        $selectQuery = "SELECT * FROM Major where Major.programmeID=4 ";
        $selectResult = mysqli_query($this->dbc, $selectQuery);
        if ($selectResult != FALSE) {
            return $selectResult;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

The select list currently only shows one major instead of two