array key search php

PHP
// Here's our fruity array
$fruits = ['apple', 'pear', 'banana'];

// Use it in an `if` statement
if (array_key_exists("banana", $fruits)) {
 // Do stuff because `banana` exists
}

// Store it for later use
$exists = array_key_exists("peach", $fruits);$arr = array(
    "one" => 1,
    "two" => 2,
    "three" => 3,
    "seventeen" => 17
);
function find($mot){
  
  global $arr; // this is global variable
  $ok=false;
 foreach ($arr as $k => $v) 
    {
      if($k==$mot){
        return $v; $ok=true; // or return true;
      }
    }
  if(ok==false){ return -1; }  // or return false;
}

//call function
echo find("two");
Source

Also in PHP: