367,6 → 367,52 |
return $aNew; |
} |
|
/** |
* Maps an array to another array using a callback function. |
* |
* Unlike array_map(), the callback is called with three parameters: the value |
* to be processed, the key of that value, and the array processed. The return |
* value of the callback defines the value for the same key of the returned |
* array. |
* |
* Because of the way the callback is called, this method supports processing |
* only one array at a time, unlike array_map(). Unlike array_walk(), this |
* function does not modify the original array. |
* |
* @param string|array $callback |
* The callback to be used for mapping array values. If an array, the first |
* element of the array is supposed to be the class name, and the second |
* element the method name of a static method to be used. |
* @param array $array |
* The array to process |
* @return array |
* @see array_map() |
* @see array_walk() |
*/ |
function array_map2($callback, $array) |
{ |
$a = array(); |
|
if (is_array($callback)) |
{ |
list($class, $method) = $callback; |
} |
|
foreach ($array as $key => &$value) |
{ |
if (is_array($callback)) |
{ |
$a[$key] = $class::$method($value, $key, $array); |
} |
else |
{ |
$a[$key] = $callback($value, $key, $array); |
} |
} |
|
return $a; |
} |
|
/** |
* Converts a string or an array of strings to an associative |
* bitmask array with the string(s) as key(s). |
472,5 → 518,16 |
|
function debug($x) |
{ |
echo '<pre>'; var_dump($x); echo '</pre>'; |
echo '<pre>'; |
|
// if (is_array($x)) |
// { |
// print_r($x); |
// } |
// else |
// { |
var_dump($x); |
// } |
|
echo '</pre>'; |
} |