$testarray = array("Computer", 30.00, 123, 321");
if(in_array('Computer' , $testarray)){
echo "yes!";
}else{
echo "no!";
}
Guys, my in_array doesn't display yes output when in the array I have the computer value inside. Why is that so?
You have a syntax error in the first line, change it to
$testarray = array("Computer", 30.00, 123, "321");
or
$testarray = array("Computer", 30.00, 123, 321);
depending on if you whant the last value to be integer or string
You try this?
$testarray = array("Computer", 30.00, 123, 321);
if(in_array('Computer' , $testarray)){
echo "yes!";
}else{
echo "no!";
}
Just a syntax error. Enable PHP display_errors to see this error.
<?php
$testarray = array("Computer", 30.00, 123, 321);
if(in_array('Computer',$testarray )){
echo "yes!";
}else{
echo "no!";
}
?>
Your syntax is be wrong!!!
Syntax error!
"
after321
and try again.