fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. function array_search_multi($array, $key, $value)
  6. {
  7. $results = array();
  8.  
  9. if (is_array($array))
  10. {
  11. if (isset($array[$key]) && $array[$key] == $value)
  12. $results[] = $array;
  13.  
  14. foreach ($array as $subarray)
  15. $results = array_merge($results, array_search_multi($subarray, $key, $value));
  16. }
  17. return $results;
  18. }
  19.  
  20. $array = array(
  21. 'item-img-list' => array(
  22. 'image-type' => 1,
  23. 'image-url' => 'http://i...content-available-to-author-only...g.pl/...'
  24. ),
  25. 'image-type' => 2,
  26. 'image-url' => 'http://i...content-available-to-author-only...g.pl/...'
  27. ),
  28. 'image-type' => 3,
  29. 'image-url' => 'http://i...content-available-to-author-only...g.pl/...'
  30. )
  31. )
  32. );
  33.  
  34. $results = array_search_multi($array, 'image-type', '2');
  35.  
  36. echo $results[0]['image-url'];
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
http://i...content-available-to-author-only...g.pl/...