Support Forums

Full Version: PHP Array Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm trying to use an array to pick out the "blacklisted" words from being used.

I'm currently trying to use this...

PHP Code:
$not_allowed = array("root","www","www2","ww3","admin","staff","dev","mail","web","cpanel","webmail","whm","host","ww2","members","member"); 

And to execute this, I'm using...

PHP Code:
if(in_array($not_allowed))
{
    
$_SESSION['error'] = $not_allowed_error;


What I want, is if anyone types any of those words in the specified text field, it will give them an error, but it's not picking them out for some reason.

Thanks.
You need the $needle part of the in_array() function.

bool in_array ( mixed $needle , array $haystack [, bool $strict ] )

So you'll do something like this.

PHP Code:
$input $_POST['input'];
if(
in_array($input$not_allowed))
{
    
$_SESSION['error'] = $not_allowed_error;

Wow!! Thank you so much! It works perfect. Smile

(rep+)