Created
October 20, 2010 11:31
-
-
Save MikePearce/636245 to your computer and use it in GitHub Desktop.
Needed to loop through a multiarray and replace {id} with something inside a class. Lambda functions FTW
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
/** | |
* Loop through the meta fields looking for things to replace | |
* @param array $replace | |
*/ | |
protected function _metaReplacements(array $replace) | |
{ | |
$doReplace = function(&$item, $key) use ($replace) { | |
foreach($replace AS $needle => $replace) { | |
$item = preg_replace('/'. $needle .'/', $replace, $item); | |
} | |
}; | |
array_walk_recursive($this->_restResponse['head'], $doReplace); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment