From Abdelkarim, 1 Year ago, written in PHP.
This paste is a reply to Re: MultiSearch Array from Abdelkarim - view diff
Embed
  1. <?php
  2.  
  3. $arr = [['lang' => null, 'title' => 'Main kaff'],
  4. ['lang' => 'en', 'title' => 'May way'],
  5. ['lang' => 'es', 'title' => 'Mi camino'],
  6. ['lang' => 'fr', 'title' => 'Mon chaimin']];
  7.  
  8. $keyValue= "en";
  9. $keyName = "lang";
  10.  
  11. function multiSearch($arr,$keyValue, $keyName)
  12. {
  13.  
  14.    return $arr[array_search($keyValue,array_column($arr,$keyName))];
  15.    
  16. }
  17.  
  18. $x = multiSearch($arr, $keyValue, $keyName);
  19.  
  20. print_r($x);
  21.  
  22. /**
  23. Array
  24. (
  25.     [lang] => en
  26.     [title] => May way
  27. )
  28. */