• 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

Split a string array into pieces

Transpose multidimensional array and join values with commas

Store multiple fields in JSON column (Nova CMS)

renameColumn migration fails for existing column with columns does not exist error

SlimExceptionHttpNotFoundException

Search for array row with specific column value and return another value from qualifying row

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

Is it possible to change the table name in the migration file-laravel

How to add automatically collapse/expand in content wordpress (single.php)?

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

wordpress function breaks wp-admin

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

How to override htaccees file for cache control header

Render the content of default_filter.php in Joomla front-end

No definition found for function in vendor vscode

About Contact Privacy policy Terms and conditions