I’m wondering if it is possible in PHP to create a custom break command/function.
For example,
<?php
$custombreak = create_function('$a', 'if ($a == 3) break 1;');
$i = 0;
do {
echo $i . '<br />';
$i++;
$custombreak($i); //<-- I'd like to break the loop with a custom function.
// if ($i==3) //<-- this is not what I'm looking for
// break;
} while ($i < 10);
?>
This is not valid PHP code but I hope you get what I’m trying to say. I’d like to escape the loop with the function.
I found a way with Exceptions.
Thanks all.