Reputation:
$modules = array(
'home' => 'home',
'login' => 'login',
'forum' => 'forum',
'topic' => 'topic',
'post' => 'post',
'profile' => 'profile',
'moderate' => 'moderate',
'search' => 'search',
'ucp' => 'usercp',
'ucc' => 'usercp',
'pm' => 'pm',
'members' => 'members',
'boardrules' => 'boardrules',
'groups' => 'groupcp',
'help' => 'help',
'misc' => 'misc',
'tags' => 'tags',
'attach' => 'attach'
);
if (in_array($modules, $_GET['module'])) {
include $_GET['module'].'.php';
}
gives:
Warning: in_array() [function.in-array]: Wrong datatype for second argument in d:\public_html\forte.php on line 24
What's wrong?
Upvotes: 0
Views: 233
Reputation: 143
From PHP.NET:
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
Make sure you're needle is: $modules
and where you're looking for it is: $_GET['module']
. I feel like you mixed those two up. It really should be written like this:
in_array($_GET['module'], $modules);
Hope that helps!
Upvotes: 0
Reputation: 319571
wrong order of variable passed to in_array
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
Upvotes: 1
Reputation: 321618
You've got the arguments mixed up - see in_array()
:
if (in_array($_GET['module'], $modules)) {
include $_GET['module'].'.php';
}
Upvotes: 10