• 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 SQL query midnight time not showing

echo language construct is discouraged. (PHP)

WooCommerce: Add/display Product or Variation custom field everywhere

Hide specific products from unlogged users based in product category in WooCommerce

Twig - How to check if variable is a number / integer

Manage independently the decimal number of the price of each product [duplicate]

Display the WooCommerce product price inside a custom function

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

laravel automatically deletes server.php on php artisan serve

CSV to PHP class properties

Get WooCommerce products from specific category

Remove categories with all childs derived from parent category

Hide email address with stars (*)

Submitting a form with ajax in Wordpress

Creating live search with AJAX and CodeIgniter

About Contact Privacy policy Terms and conditions