array combine

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello newsgroup,
A Note that I just posted in the PHP manual at the page describing
the array_combine() function:
contains this code:

function array_combine_emulated( $keys, $vals ) {
 $keys = array_values( (array) $keys );
 $vals = array_values( (array) $vals );
 $n = max( count( $keys ), count( $vals ) );
 $r = array();
 for( $i=0; $i<$n; $i++ ) {
  $r[ $keys[ $i ] ] = $vals[ $i ];
 return $r;

I did take great care as it was my first ever contribution to the User
Contributed Notes, but still a nasty mistake slipped in: instead of the use
of the function max() in the example code given, there should of course have
been either a call to min(), or some padding mechanism for the shorter
array. It 's too embarrassing to add another note about, so for the record I
figured this newsgroup might be more appropriate.
Must be the thrill of contributing,

Re: array combine

On Fri, 02 Sep 2005 15:07:44 +0200, Ivo wrote:

Quoted text here. Click to load it
Quoted text here. Click to load it

I imagine many more people read the online manual than read this group
though. Can't see why you'd be too embarrased (everyone makes mistakes),
but surely it would be less embarrasing to post your own correction
there before someone else does :)
(Remove REMOVE for email address)  

Re: array combine

Ivo wrote:

Quoted text here. Click to load it

Don't worry man. :-)
You ARE contributing, so you are OK.

The good news: Sometimes, when some has time for it, they  
scan through the contributions and clear them up a bit. Happened to some of  
my 'great remarks' on ;-)

So: Just repost your improved code, with a remark that the original was  
wrong, and eventually your original posting will be deleted.

Best wishes and good weekend.

Erwin Moller

Site Timeline