I'm taking an array of automatically keyed values, and want to copy
the values to the key as well.

Is there a better way to write this than either of the below? The
foreach + tempvar version bothers me :)

$arr = array( 1, 2, 3 ) ;

then -

$arr = array_combine(array_values($arr), array_values($arr));

or (ew) -

foreach( $arr as $a ) {
  $arr2[$a] = $a ;
}
$arr = $arr2 ;

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to