• 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

Alert message after submitting form in PHP

Insert And Retrieve Data in MySQL with $.post Noob Question

Laravel SQL query midnight time not showing

wordpress function breaks wp-admin

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

MongoDB Duplicate Documents even after adding unique key

Autoloading classes in PHPUnit using Composer and autoload.php

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

how to prevent float variables displaying as scientific notation when printing [duplicate]

Converting alphabet letter to alphabet position in PHP [duplicate]

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Download & Save Zoom Recording in directory by PHP

Handling expired token in Laravel

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

phpseclib 2.0 can not use Composer to create autoload

About Contact Privacy policy Terms and conditions