Newbie needed help with searching within arrays

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
EODC
Forum Newbie
Posts: 9
Joined: Fri Feb 26, 2010 4:06 am

Newbie needed help with searching within arrays

Post by EODC »

Hi Everyone - joined the forums as looking for a decent place to learn some more PHP (Im a beginner so please be nice!)

So my first ask for help is as follows!

I am working on a Ban feature for my forums, and what i woudl like to do, is search within an array, and if an exact match is found, execute the statment...

my current code...

Code: Select all

 
<if test="in_array( $this->member->getProperty['name'] , explode(',' , $this->settings['eodc_chat_bar_ban']))">
{
 
}
</if>
 
What its currently doing, is when I am adding a "name" it will execute the function even if one letter of the name is present.

For example if i want to ban Monkey, and I only type in M it will still ban Monkey. I want it to require the WHOLE name, I think it needs a == but i dont know what to do!!!

Any help would be greatly appreciated!

Many thanks
EODC
Forum Newbie
Posts: 9
Joined: Fri Feb 26, 2010 4:06 am

Re: Newbie needed help with searching within arrays

Post by EODC »

Anyone???
EODC
Forum Newbie
Posts: 9
Joined: Fri Feb 26, 2010 4:06 am

Re: Newbie needed help with searching within arrays

Post by EODC »

OK So i did it :D

Code: Select all

 
         $memberName = $ipbRegistry->member()->getProperty('name');
         $banned = $settings['eodc_chat_bar_ban'];
         $ban = explode(' ' , $banned);
 
if (in_array( $memberName , $ban))
{
}
else
{
 
Post Reply