array combine

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivo

    array combine

    Hello newsgroup,
    A Note that I just posted in the PHP manual at the page describing
    the array_combine() function:
    <URL: http://www.php.net/array-combine#56424 >
    contains this code:

    function array_combine_e mulated( $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,
    ivo













  • Dave

    #2
    Re: array combine

    On Fri, 02 Sep 2005 15:07:44 +0200, Ivo wrote:
    [color=blue]
    > Hello newsgroup,
    > A Note that I just posted in the PHP manual at the page describing
    > the array_combine() function:[/color]
    <snip>[color=blue]
    > 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,
    > ivo
    > http://4umi.com/web/[/color]

    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 :)
    --
    Dave <dave@REMOVEbun dook.com>
    (Remove REMOVE for email address)

    Comment

    • Erwin Moller

      #3
      Re: array combine

      Ivo wrote:
      [color=blue]
      > Hello newsgroup,
      > A Note that I just posted in the PHP manual at the page describing
      > the array_combine() function:
      > <URL: http://www.php.net/array-combine#56424 >
      > contains this code:
      >
      > function array_combine_e mulated( $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,
      > ivo
      > http://4umi.com/web/[/color]

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

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

      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.

      Regards,
      Erwin Moller

      Comment

      Working...