Need help with stristr statement with 6 conditions
Posted: Fri Feb 26, 2010 2:08 pm
I am new to php and am seeking an answer to this problem.
I am trying to write and evaluative script that searches a submitted string
known as $response for six seperate values which must all be present for the
response to be correct. I am unsure as to how I should be expressing this properly.
This is as close to a proper expression as I can seem to get. I have found many
examples of how to find one needle in a haystack but how do you find all six?
Losing my mind over this for two days now. Any help is appreciated.

I am trying to write and evaluative script that searches a submitted string
known as $response for six seperate values which must all be present for the
response to be correct. I am unsure as to how I should be expressing this properly.
This is as close to a proper expression as I can seem to get. I have found many
examples of how to find one needle in a haystack but how do you find all six?
Code: Select all
<?php
$response = $_POST[Q1Answer];
if (stristr($response,'magna carta')) &&!(stristr($response,'mayflower compact')) &&!(stristr($response,'declaration of independence')) &&!(stristr($response,'articles of confederation')) &&!(stristr($response,'constitution')) &&!(stristr($response,'bill of rights'))
{
echo "You wrote ";
echo $response;
echo " That is Correct";
}
else
{
echo "You wrote ";
echo $response;
echo " That is Incorrect";
}
?>