Re: Re: check a variable after EACH function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/7/1 Nisse Engström <news.NOSPAM.0ixbtqKe@xxxxxxxx>:
> On Tue, 30 Jun 2009 18:31:54 -0500, Flint Million wrote:
>
>> Suppose I have some kind of check variable - say for example
>> $abort_now. Or it could be a function. Something to be evaluated to a
>> value.
>>
>> I want to execute a block of statements, but after EACH statement
>> executes, check the value of $abort_now and if it is true, break; out
>> of the block.
>>
>> Here's an example
>>
>> do {
>>   do_something();
>>   do_something_else();
>>   do_another_thing();
>>   do_yet_another_thing();
>>   and_keep_doing_things();
>> } while ($abort_now != 1);
>
> I would have the functions return true or false and
> do something like:
>
>  while (do_something()         &&
>         do_something_else()    &&
>         do_another_thing()     &&
>         do_yet_another_thing() &&
>         and_keep_doing_things())
>    ;
>
>
> /Nisse
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I think you *could* do something like this:

<?php

$functions = array('do_something', 'do_something_else',
'do_another_thing', 'do_yet_another_thing', 'and_keep_doing_things');

foreach ($functions as $function) {
    $function();
    if ($abort_now == 1) break;
}

?>

The catch is that in this case all the functions would have to accept
the same parameters.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux