• 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

Add 2 Webcam in one page with WebcamJS

SQLSTATE[HY000]: General error: 1 table posts has no column named *

Smarty if isset

Error when uploading certain .png files "Interlace handling should be turned on when using png_read_image"

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Show Custom Data in Woocommerce Order Details Admin Area

Querying only one row from a one to many relationship laravel

Problem with fetching data from database in Laravel

Laravel You requested 1 items, but there are only 0 items available

Normalize DateInterval in PHP

Transpose and flatten multiple rows of array data [duplicate]

Laravel 5 session not persisting after user is logged in

PHP drop down list using array's and foreach (else and for) code

How do I enable error reporting in Laravel?

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

About Contact Privacy policy Terms and conditions