mercredi 12 septembre 2018

PHP - Seach in specific array value

I Want to Search in Array value by in_array Function and For loop . My code :

$input = "a";
$arrays = array("cdf","abs","tgf");

$counter = count($arrays);

for ($i=0; $i<$counter; $i++){

    if(in_array($input,$arrays) !== true){
        echo "Found <br>";
    } else {
        echo "Not Found";
    }

}

Output :

Not Found
Found
Not Found

But , if(in_array($input,$arrays[$i]) !== true) not working.

Aucun commentaire:

Enregistrer un commentaire