• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to break out of a foreach once a condition is met?

phploopsforeachconditional


PHP Snippet 1:

if ($small_object->TIME == $sought_time) {
   break;       
}

PHP Snippet 2:

   $count = 0;
    ......
    ..
    ..
    ..
    ..
    ......    
    if (++$count == 5) break;

Related Snippets

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

oauth-private.key does not exist or is not readable

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

Insert And Retrieve Data in MySQL with $.post Noob Question

How to map the two arrays with a duplicate value?

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

Which is faster php date functions or carbon?

PHP: set a (deep) array key from an array [closed]

Check if string contains a value in array [duplicate]

Query Optimization, changing the queries in the loop into a single processing query

JQuery content editable div and text box on submit not sending POST

passwordless LDAP login and get user information using Kerberos ticket in PHP

Laravel UUID generation

About Contact Privacy policy Terms and conditions