• 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

Adding one microsecond to Datetime object in PHP

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

How to redirect to another page after n seconds in wordpress without using javascript?

Smarty if isset

How to change product Image when variables are selected in Shop and Archive Pages?

Add record for each array elements if missing in table

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Detect a fetch request in PHP

Could not decode a text frame as UTF-8.

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

How can I create a Download Page with post php method?

How to Generate PDF invoice to XML format using mPDF

nginx err_connection_refused, can anyone help me?

PHP mail sending empty mails

Pagekite error: FAIL: localhost:8080 is down

About Contact Privacy policy Terms and conditions