Created
March 11, 2011 20:39
-
-
Save loonies/866527 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Applys a function to a specific set of keys in an array | |
* | |
* @param array & $source_array the array to apply the callback to | |
* | |
* @return null | |
*/ | |
public function apply( & $source_array, $callback, $keys) | |
{ | |
if (true === $keys) | |
{ | |
array_walk($source_array, $callback); | |
} | |
else | |
{ | |
foreach ($keys as $key) | |
{ | |
$source_array[$key] = call_user_func($callback, $source_array[$key]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment