Tech Tip: Combine Arrays
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: January 12, 2015
Below is an utility method to combine 2 or more arrays together. Arrays must be of the same type.
// Method: Php_Combine_Array // Parameters // $1 - Pointer to array that will contain the result // ${2} - Pointer to the arrays to combine // ---------------------------------------------------- ARRAY POINTER($arrP;0) C_POINTER($1;${2}) C_POINTER($arrResult;0) $arrResult:=$1 $paramLength:=Count parameters If ($paramLength>1) For ($i;2;$paramLength) APPEND TO ARRAY($arrP;${$i}) $pointer:=$arrP{$i-1} $err:=PHP Execute("";"array_merge";$arrResult->;$arrResult;$pointer) End for End if |
Note: the result array($arrResult) should be different than the arrays being combined.