BREAK
The break statement is used to jump out of a loop completely.
Example
The following code looks for the first user that is inactive, print the users name and then breaks out of the loop.
$users = [
[
"id" => "31294",
"status" => "active",
"name" => "Alex Garcia"
],
[
"id" => "90453",
"status" => "inactive",
"name" => "Alex Garcia"
],
[
"id" => "42271",
"status" => "active",
"name" => "Alex Garcia"
],
]
FOREACH ($users AS $user) {
IF($user['active'] === 'inactive') {
:: $user['name']
BREAK
}
}
Copyright ©2013-2022 SunSed®. All rights reserved.