fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $array =[
  6. [
  7. 'col_1' => 'one',
  8. 'col_2' => 'two'
  9. ],
  10. [
  11. 'col_5' => 'five',
  12. 'col_3' => 'three'
  13. ]
  14. ];
  15.  
  16. $key = -1;
  17.  
  18. foreach($array as $k => $el) {
  19. if (array_search('three', $el) !== false) {
  20. $key = $k;
  21. break;
  22. }
  23. }
  24. echo $key;
Success #stdin #stdout 0.01s 82560KB
stdin
Standard input is empty
stdout
1