• 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 query builder binding parameters more than once

Laravel SQL query midnight time not showing

Wordpress add responsive srcset header image to theme

Using array_intersect on a multi-dimensional array

Substitute integers and dots with regex [duplicate]

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

Laravel phpunit test failing authorization

Target Individual Form Instance/Counter Inside A PHP While Loop

Why isn't my PHP exception working?

Pass a select with mysqli_fetch_row to a table

Redirect to previous page with php

How to increase the PHP upload limits [duplicate]

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

Show date difference as "20" instead of "20 years ago"

How do I loop through an MS SQL database with VB.NET?

About Contact Privacy policy Terms and conditions