Re: [PHP4BETA] problems with array_walk
| From: | Faisal Nasim | Date: | Thu, 13 Apr 2000 16:02:52 +0000 |
| Subject: | Re: [PHP4BETA] problems with array_walk | ||
| References: | 1 2 3 4 5 6 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13509@lists.php.net to get a copy of this message | ||
: On Thu, 13 Apr 2000, Faisal Nasim wrote:
: > Maybe you should allow a boolean flag or perhaps a new function
: > say 'array_walk_r'?
:
: Why would you _not_ want to have array reset automatically?
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