• 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

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

Sum array values of a column within each column of an array with 3 levels

CodeIgniter 4: Like and Dislike Functionality

Move a child array to parent array and change parent/child name

How to install LDAP in Docker php-fpm alpine

Adding one microsecond to Datetime object in PHP

find in set in laravel ? example

(Cache::lock()) -> get() -- Under what conditions does it return false?

HTML and PHP in one file

shell errors running php exec

How to add class name to an existing tag in php

How to execute sql code based on fetch array

Artisan, creating tables in database

PHP rotate matrix counter-clockwise

Symfony - "framework.test" config is not set to true

About Contact Privacy policy Terms and conditions