Answers for "php find string in array and return index"

PHP
10

get index of element in array php

$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array);   // $key = 1;
Posted by: Guest on September-24-2020
0

php find part of string in array

foreach($array as $item){
  if(strpos($item,"mysearchword")!== false){
    echo 'found';
  }
}
Posted by: Guest on May-05-2021

Code answers related to "php find string in array and return index"

Browse Popular Code Answers by Language