Re: comparing a string
| From: | tedd | Date: | Tue, 20 Jun 2006 14:02:21 +0000 |
| Subject: | Re: comparing a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238401@lists.php.net to get a copy of this message | ||
At 12:43 PM +0100 6/20/06, Ross wrote:
>I have a quiz where the ansers are held in a array called $correct answers.
>When I compare the string
>
>if ($_REQUEST['x']= $correct_answers[$page-1]) {
>
>
>
>with a double == the answer is always correct with the single = it is always
>wrong.
>
>when I echo out the posted answer and the value from the answers arrray they
>are correct.
When you say == the answer is always correct -- does that mean even when the answer is wrong? If so,
then there's something else going on here.
But, I believe the answer is:
if ($_REQUEST['x'] == $correct_answers[$page-1]) {
This will compare the two and if they are the same will report true. You should read the manual.
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com