Advertisement
Guest User

Untitled

a guest
May 27th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. <?php
  2. function recursive_array_search($needle, array $haystack) {
  3. foreach ($haystack as $key => $value) {
  4. if ($value === $needle) {
  5. return $key;
  6. }
  7. if (is_array($value)) {
  8. $chideKey = recursive_array_search($needle, $value);
  9. return [$key, $chideKey];
  10. }
  11. }
  12. }
  13. $data = [
  14. 'a',
  15. 'b',
  16. [
  17. 'aa',
  18. 'bb'
  19. ]
  20. ];
  21. $ret = recursive_array_search('bb', $data);
  22.  
  23. var_dump($ret);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement