Created
November 16, 2014 04:21
-
-
Save mikedfunk/8e0733610d4a4fa8bc53 to your computer and use it in GitHub Desktop.
optionally allow an array in php
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 | |
// ... | |
public function processData($input) | |
{ | |
if (is_array($input)) { | |
// if it's an array, loop through each one and recursively | |
// call the function we're in but this time without an | |
// array. So it should skip past this line for each one. | |
return array_map([$this, 'processData'], $input); | |
} | |
// process an individual item here since it is not an array... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment