• 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

Installing Composer - Internal Error

Send same name multiple checkbox values via ajax

How to convert time from one timezone to another in PHP

PHP Include for HTML?

Display the WooCommerce product price inside a custom function

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

Laravel eloquent update record without loading from database

PHPExcel_IOFactory::createWriter causes wrong behaviour

advanced custom fields wordpress custom class

How can I easily switch between PHP versions on Mac OSX?

Creating a config file in PHP

Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning

How can I format this number correctly using PHP?

JQuery content editable div and text box on submit not sending POST

Nginx RTMP not recording

About Contact Privacy policy Terms and conditions