• 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

Creating Combinations of Elements

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Wordpress wpdb->delete issue

woocommerce_wp_select options array from product attribute terms

Creating command to backup MySql database in Laravel

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

How to get page number on dompdf PDF when using "view"

Detect emoticons in string

Target Individual Form Instance/Counter Inside A PHP While Loop

api response laravel doesn't show

Don't show recurring price for WooCommerce subscriptions worth 0$

php file upload scanning using clamav, permissions on /tmp/

how to get the header value, if we don't know the value because the value is random from the server

Undefined variable in Laravel 8 project (php 7.4)

loop through an anchor id

About Contact Privacy policy Terms and conditions