Page 1 of 1

Check array php

Posted: Mon Dec 26, 2011 3:14 pm
by dmallia
I am assinging an array

Code: Select all

 $alphabet = array();
than i am inserting data in it by a loop ex.

Code: Select all

$alphabet [$i] = A;
$alphabet [$i] = B;
Now i want that, if a user enters A and and A is already in the array it will give him an error msg. So i want a script that gets what is stored in the variable(the button that the user chose) and than checks the array if it's already added and if it's added it displays the message.

Any body know how I can do it? I think i need to use a loop but still do not know what is the best choise.

Re: Check array php

Posted: Mon Dec 26, 2011 4:34 pm
by Celauran

Re: Check array php

Posted: Tue Dec 27, 2011 2:27 pm
by dmallia
thanks script worked fine :D