• 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 Command Schedule Not Working Properly

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

Unable to guess the mime type as no guessers are available Laravel 5.2

Show only featured products in Woocommerce shop page

PHP random string generator

Where do I need to place a hook for phpunit?

Encrypt in php and decrypt in Dart(flutter)

Get number of working days between two dates in PHP [duplicate]

phpseclib 2.0 can not use Composer to create autoload

PHP web3 ERC20 token function call

image source not readable

How to install LDAP in Docker php-fpm alpine

Performance of foreach, array_map with lambda and array_map with static function

Multiply each value in array using array_map function

Laravel Multi-language routes without prefix

About Contact Privacy policy Terms and conditions