|
Posted by Ewoud Dronkert on 06/06/05 19:31
On 6 Jun 2005 06:49:37 -0700, pauld wrote:
> help please ?
Tested and working:
$a = array( 'one' => 1, 'two' => 2, 'three' => 3 );
// solution 1
$b = $a;
foreach ( $b as $k => $v ) $b[$k] = 0;
print_r ( $b );
// solution 2 (PHP5)
$b = $a;
foreach ( $b as &$v ) $v = 0;
print_r ( $b );
// solution 3
function zero() { return 0; }
$b = array_map( 'zero', $a );
print_r ( $b );
// solution 4
$b = array_combine( array_keys( $a ), array_fill( 0, count( $a ), 0 ) );
print_r ( $b );
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Navigation:
[Reply to this message]
|