Page 1 of 1

Newbie needed help with searching within arrays

Posted: Fri Feb 26, 2010 4:11 am
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

Re: Newbie needed help with searching within arrays

Posted: Fri Feb 26, 2010 6:07 am
by EODC
Anyone???

Re: Newbie needed help with searching within arrays

Posted: Fri Feb 26, 2010 7:17 am
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
{