Check array php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dmallia
Forum Commoner
Posts: 25
Joined: Sat Nov 19, 2011 3:18 pm

Check array php

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Check array php

Post by Celauran »

dmallia
Forum Commoner
Posts: 25
Joined: Sat Nov 19, 2011 3:18 pm

Re: Check array php

Post by dmallia »

thanks script worked fine :D
Post Reply