• 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

Need to display only array value in JSON output

Jquery DataTables: Data not displaying in table via Ajax

Phpunit partial mock + proxy Entity

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

printing all running session variable in laravel 5.1

Get latest Tweets - What API

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

Woocommerce Checkout - Add conditional field required if one field is filled

Laravel insert dynamic input values with radio button

Exact alternate to mcrypt_encrypt in PHP 7.2

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

Laravel Passport - Not able to get token string in response?

Add 2 Webcam in one page with WebcamJS

Adding multiple items to WooCommerce cart at once

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

About Contact Privacy policy Terms and conditions