do I need to use break here or will it stop looping and just return once?
for($i = 0; $i < 5; $i ++) {
if($var[$i] === '') return false;
// break;
}
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It will run just once, stop looping, and exit from the function/method.
It could be argued though that this is bad style. It is very easy to overlook that
returnlater, which is bad for debugging and maintenance.Using
breakmight be cleaner: