By using this code, you agree to the following terms...
1) You may use
this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
//**************************************
//
// Name: array_merge_assoc
// Description:Works on a like idea as a
// rray_merge(), but instead of concatenati
// ng arrays, it takes two related indexed
// arrays and creates one associative array
// .
If $keyarray is NOT greater or equal to $valuearray the function will error unless the optional $force=TRUE
// By: Markus Diersbock
//
// Inputs:$keyarray, $valuearray, $force
// (optional)
//
// Returns:assoc array or error string
//
//This code is copyrighted and has // limited warranties.Please see http://
// www.Planet-Source-Code.com/vb/scripts/Sh
// owCode.asp?txtCodeId=1200&lngWId=8 //for details. //**************************************
//
/*
Name: array_merge_assoc
Author: Markus Diersbock
Details: Takes two related indexed arrays and
combines them into one associative array.
Notes: If $keyarray is NOT greater or equal to $valuearray
the function will error unless the optional $force=TRUE
Revisions: 2003/12/13 - Created
2004/01/14 - Added code for unequal arrays
*/
function array_merge_assoc($keyarray, $valuearray, $force=FALSE){
$i=0;
if ((count($keyarray) >= count($valuearray)) || $force==TRUE) {
foreach($keyarray as $element){
$aryreturn[$element]=$valuearray[$i++];
}
} else {
return 'Arrays are not of equal size';
}
return $aryreturn;
}