Re: [PHP4BETA] problems with array_walk
| From: | Andrei Zmievski | Date: | Thu, 13 Apr 2000 16:04:52 +0000 |
| Subject: | Re: [PHP4BETA] problems with array_walk | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13508@lists.php.net to get a copy of this message | ||
On Thu, 13 Apr 2000, Faisal Nasim wrote:
> You might be running a loop and for some condition you want
> to pass it to array_walk for the rest of the entries..... Better
> explain by example:
>
> $a = array ( "faisal" , "nasim" , "whiz" , "kid" ,
> "FLAG" , "value" ,
> "value2" );
>
> while ( $x = current ( $a ) )
> {
> if ( $x == 'FLAG' )
> {
> next ( $a );
> array_walk ( $a , 'blah' ); // don't want to reset!
> break;
> }
> print "ORDINARY VALUE: $x\n";
> next ( $a );
> }
>
> function blah ( &$val )
> {
> print "=== CAUGHT SECRET VALUE $val\n";
> }
>
>
> Output:
>
> ORDINARY VALUE: faisal
> ORDINARY VALUE: nasim
> ORDINARY VALUE: whiz
> ORDINARY VALUE: kid
> === CAUGHT SECRET VALUE value
> === CAUGHT SECRET VALUE value2
Seems like a pretty contrived example...
-Andrei
* There is no knowledge that is not power. *