• 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

PHP: Telegram Bot: Insert line break to text message

Call to a member function fetch_field() on a non-object MySQLiDB

How to check user Permissions using Custom Middleware in Laravel

Wordpress wpdb->delete issue

PHP array stringify

How to MODIFY a Google Docs document via API using search-and-replace?

PHP drop down list using array's and foreach (else and for) code

Update Order custom Field value with WooCommerce REST API

How do I upload a laravel project on cPanel shared hosting?

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

Additional price based on cart item count in WooCommerce

Laravel Model save() & update() Not Saving

sort() not affecting original array while inside foreach loop

Insert multidimensional array to codeigniter cart

How to get total pages of PDF with FPDF?

About Contact Privacy policy Terms and conditions