• 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

Server-sent events in PHP (without echo or print)

str_word_count() function doesn't display Arabic language properly

Assign output of PHP function to a variable

Adding the custom page with add_menu_page function on Wordpress

PHPMyAdmin not working as intended at remote server. Error 500, $respond not found

Wordpress how to get the post thumbnail inside a figure tag

How to convert a carbon into string, to take the date only?

Undefined variable in Laravel 8 project (php 7.4)

Custom post type single page not working

Star rating with half star support

Not able to override collapsible.js in magento 2

How to to send mail using gmail in Laravel?

Multiply each value in array using array_map function

Calculating Median of an array in PHP

How to edit Records using CodeIgniter

About Contact Privacy policy Terms and conditions