break out of if and foreach

I have a foreach loop and an if statement. If a match is found i need to ultimately break out of the foreach.

foreach ($equipxml as $equip) {

    $current_device = $equip->xpath("name");
    if ($current_device[0] == $device) {

        // Found a match in the file.
        $nodeid = $equip->id;

        <break out of if and foreach here>
    }
}

4 Answers
4

Leave a Comment