while ( ... ) { if (!$flag && check_whatever()) { do_whatever(); $flag = 1; } }