Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Simon has already answered has already answered while I was writing something similar:

foreach(array('best', 'average', 'bad') as $rank) {
 if($row[$rank]) {
 $id = $row[$rank];
 break;
 }
}

Note however, that in both this and Simon's answer, there is a possibility of $id never being assigned a value. Konijn's answer Konijn's answer avoids that (although $id might still end up false'y)

Simon has already answered while I was writing something similar:

foreach(array('best', 'average', 'bad') as $rank) {
 if($row[$rank]) {
 $id = $row[$rank];
 break;
 }
}

Note however, that in both this and Simon's answer, there is a possibility of $id never being assigned a value. Konijn's answer avoids that (although $id might still end up false'y)

Simon has already answered while I was writing something similar:

foreach(array('best', 'average', 'bad') as $rank) {
 if($row[$rank]) {
 $id = $row[$rank];
 break;
 }
}

Note however, that in both this and Simon's answer, there is a possibility of $id never being assigned a value. Konijn's answer avoids that (although $id might still end up false'y)

Source Link
Flambino
  • 33.3k
  • 2
  • 46
  • 90

Simon has already answered while I was writing something similar:

foreach(array('best', 'average', 'bad') as $rank) {
 if($row[$rank]) {
 $id = $row[$rank];
 break;
 }
}

Note however, that in both this and Simon's answer, there is a possibility of $id never being assigned a value. Konijn's answer avoids that (although $id might still end up false'y)

lang-php

AltStyle によって変換されたページ (->オリジナル) /