Answers for "check if string include letters"

PHP
2

How do I check if a string contains a specific word?

$a = 'Hello world?';

if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
    echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
    echo 'true';
}
Posted by: Guest on May-18-2020
0

check if character is available in string

function mutation(arr) {
 let first = arr[0].toLowerCase();
 let second = arr[1].toLowerCase();

  for(let i = 0; i < second.length; i++) {
    if(first.indexOf(second[i]) < 0) return false;
  }

  return true;
}

mutation(["hello", "hey"]);
Posted by: Guest on September-04-2021

Code answers related to "check if string include letters"

Browse Popular Code Answers by Language