Forum Moderators: coopster

Message Too Old, No Replies

preg match radio values

why undefined offset?

         

henry0

3:51 pm on Jan 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is the result of multiple radio button via $_POST
and print_r results in:

Array
(
[1] => y
[2] => y
[3] => n
)

I want to make sure that I receive the expected values so this check it out:

$answer=$_POST['answer'];

if (!preg_match("/^[a-z]+$/",$answer[$counter]))
{
echo "<h3>Intrusion tentative</h3>";
exit();
}

But it results in:
Notice: Undefined offset: 0
which is: if (!preg_match("/^[a-z]+$/",$answer[$counter]))

I used this many times (altough not with radio)
what am I not considering?

RonPK

3:59 pm on Jan 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, your array starts counting at 1, so there is no $answer[0].

How are you defining $counter?

henry0

4:08 pm on Jan 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks,
I looked at it for a long time
my mistake; the counter was set at 0