每个循环的php找到最低值

There are several options for one item. I.e. Item1 --> Option1: black, white, pink Option2: Small, Medium, Large --> each option is either available(1) or not available(0).

So if someone chooses Item1 with color black and size small the status should be returned based on availability.

My code is the following:

foreach ($item['option'] as $option) {
if ($option['availability']=0) { echo 'Not available'; } else { echo 'Available'; } }

So far so good. My problem is that I only want to print the status message only once, because the item with the configuration is either available or unavailable. With the above code I get twice the echo 'Not available' if both options in the example above are unavailable. I only would like to print :Not available' only once even if several options are unavailable. How can that be achieved?

I hope my question/problem is clear. Thank you for your help!

Use '==' because you are comparing the values and you can use break to stop the loop.

foreach ($item['option'] as $option) {
        if ($option['availability']==0) { 
            echo 'Not available'; 
            break; 
        } else { 
            echo 'Available'; 
            break;
        } 
}

You can break; the loop or just exit it, exit;.

(This had to be a answer as i am not able to put it as a comment*