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 long do php sessions last?

564


How do you identify independent and dependent variables in regression analysis?

490


When are you supposed to use endif to end the conditional statement?

541


Is json a string php?

528


What is the method to execute a php script from the command line?

556






What should we do to be able to export data into an excel file?

517


How long will it take to learn php?

513


Do you know what is the difference between the include() and require() functions?

519


How do I find out the number of parameters passed into function9?

550


Is it possible to extend the execution time of a php script?

500


Tell me how to set a page as a home page in a php based site?

517


What is difference between session_unset and session_destroy?

506


Which methods should be used for sending an email using the variables $to, $subject, and $body?

568


What is string and its function?

517


Why do you need php?

526