How can I check if a value is already in an array?

Answer Posted / deep

The above answer is correct. I will just add a complete
example.

<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os))
{
echo "Got Irix";
}
if (in_array("mac", $os))
{
echo "Got mac";
}
?>

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is the ternary conditional operator used in php?

508


What websites use php?

508


How to read a file in binary mode?

625


What is static in php?

529


How to download file in php?

545






Tell me what does the php error 'parse error in php - unexpected t_variable at line x' means?

550


How to randomly retrieve a value from an array?

542


What is difference between include,require,include_once and require_once()?

516


What is the most common http method?

505


What is composer used for?

501


How do you measure variables?

506


What is the purpose of constant() function?

509


Tell me how can we connect to a mysql database from a php script?

493


Is python better than php?

495


What is encapsulation in php with example?

546