You are hereArray / PHP: array_combine() for PHP < 5

PHP: array_combine() for PHP < 5


I developed a script to process extensively arrays, and I need to combine some array. I got error

Fatal error: Call to undefined function: array_combine() in ...

It seems function array_combine() only implemented in PHP 5. So I was looking for the solution. There is solution I found.

Insert the code below ....

if(!function_exists('array_combine')){
function array_combine($keys, $values){
if(count($keys) < 1 || count($keys) != count($values) || !is_array($keys) || !is_array($values)){
return false;
}

$keys = array_values($keys);
$values = array_values($values);
for($x=0; $x < count($keys); $x++){
$return_array[$keys[$x]] = $values[$x];
}

return $return_array;
}
}



Syndicate

Syndicate content

Navigation

AdSense