Voting

: six minus one?
(Example: nine)

The Note You're Voting On

welcome at el hyphen mustafa
9 years ago
Further to loreiorg's script
in order to preserve duplicate keys when combining arrays.

I have modified the script to use a closure instead of create_function

Reason: see security issue flagged up in the documentation concerning create_function

<?php

function array_combine_($keys, $values){
$result = array();

foreach (
$keys as $i => $k) {
$result[$k][] = $values[$i];
}

array_walk($result, function(&$v){
$v = (count($v) == 1) ? array_pop($v): $v;
});

return
$result;
}

?>

<< Back to user notes page

To Top