如何检查单词是否在数组中然后返回匹配的单词

Question 1

I'm using the following to check for bad words from some input element, and i want to tell the user which word on their text is not allowed. How do i get that specific word or words from the array that matched it? And how when user entered more than one bad word this only detects the first word and ignores the rest.

Question 2.

How do i ignore lower and upper cases, this code doesn't recognize "John" and "john" as the same thing. I don't know if this is a regex job. Please reccomend another way if this is weak. PHP

$BadWords = array("James", "June", "Jane");
if (in_array($comment, $BadWords)){
    echo 'No way... that is not allowed lol...';
}

Question 3 (Speed)

Say i have around 2000 words to compare a word against, which way is the best to do this process faster without misuse resources while taking into account that filtering bad words is just an example as this is not limited to checking bad words and at all cases not considering databases.

Thanks.

Use the array_search to get the matched words from the key

 <?php
$comment="James";
$BadWords = array("James", "June", "Jane");
$bwords = array_map('strtoupper',$BadWords);
if (in_array(strtoupper($comment), $bwords)){
    $k=array_search($comment,$bwords);
    echo $BadWords[$k]."
";
    echo 'No way... that is not allowed lol...';
}

You can use below snippet it will work lower and upper cases

$comment="James"; // 'james'
$BadWords = array("James", "June", "Jane");
$lowerCap = array_map('strtolower', $BadWords);
  if (in_array(strtolower($comment), $lowerCap)){
    $k=array_search($comment,$lowerCap );
    echo $BadWords[$k]."
";
    echo 'No way... that is not allowed lol...';
}

Combining both the above answers, this will detect if there is more than one badword and also if it's concatenated with any other string:

$comment="James junexyz";
$BadWords = array("James", "June", "Jane");
foreach($BadWords as $k=>$v){
    $pos = stripos($comment,$v);
    if($pos!==false){
        echo $v. ' is not allowed'.'<br>';
    }
}

Demo