Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Created November 14, 2013 03:01
Show Gist options
  • Select an option

  • Save simkimsia/7460610 to your computer and use it in GitHub Desktop.

Select an option

Save simkimsia/7460610 to your computer and use it in GitHub Desktop.
Method for the ReplaceableBehavior.php in https://gist.github.com/simkimsia/7460467
/**
* Replace all occurrences of unicorn in an array with super_duper_unicorn
*
* @param Model $Model
* @param array $array
* @return array
*/
public function replaceWithSuper(Model $Model, $array = array()) {
foreach ($array as $key => $value) {
if (is_string($value) && $value == 'unicorn') {
$array[$key] = 'super_duper_unicorn';
}
}
return $array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment