You are here: array combine « PHP Programming Language « IT news, forums, messages
array combine

Posted by Ivo on 09/02/05 16:07

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_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,
ivo
http://4umi.com/web/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация