• 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

Filter array by skipping every nth element from the end

enable Apache http Authorization header

merge all files in directory to one text file

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

Symfony run hint kernel.secret parameter not found

Limit of log line written to Apache Errorlog from mod php error_log

best way to store error messages in Laravel (session or variable)

Facebook PHP SDK - will not logout properly

Sum column values from multiple arrays

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

Laravel display validation error

Limit login attempts in Laravel 5.7

Smarty if isset

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Using spatie/media-library, how to rename a collection of uploaded files?

About Contact Privacy policy Terms and conditions