Skip to content

Instantly share code, notes, and snippets.

@loonies
Created March 11, 2011 20:39
Show Gist options
  • Save loonies/866527 to your computer and use it in GitHub Desktop.
Save loonies/866527 to your computer and use it in GitHub Desktop.
<?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