[pmwiki-users] Avoiding the in_array() PHP built-in function
Patrick R. Michaud
pmichaud at pobox.com
Wed Mar 29 20:57:23 CST 2006
On Wed, Mar 29, 2006 at 07:15:46PM -0700, H. Fox wrote:
> What is a better way of doing the following:
>
> $Actions_allowed =
> array('browse','print','search','edit','login', 'rss', 'atom');
> if (! in_array($action, $Actions_allowed)) { # Do something. }
I tend to use things like:
$Actions_allowed = array(
'browse' => 1, 'print' => 1, 'search' => 1, 'edit' => 1,
'login' => 1, 'rss' => 1, 'atom' => 1);
if (!@$Actions_allowed[$action]) { # Do something }
Pm
More information about the pmwiki-users
mailing list