Array

Array

am 10.08.2009 14:28:32 von Ron Piggott

------=_NextPart_000_0039_01CA1994.8BB35380
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

How do I change this ELSEIF into an array?

} elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> =
"verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( =
$page <> "member_services_login" ) AND ( $page <> =
"member_services_logoff" ) AND ( $page <> "resource_center" ) AND ( =
$page <> "network" ) ) {
------=_NextPart_000_0039_01CA1994.8BB35380--

Re: Array

am 10.08.2009 14:33:34 von Jonathan Tapicer

On Mon, Aug 10, 2009 at 9:28 AM, Ron
Piggott wrote:
> How do I change this ELSEIF into an array?
>
> } elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> "v=
erse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page =
<> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND =
( $page <> "resource_center" ) AND ( $page <> "network" ) ) {

Something like:

} elseif (!in_array($page, array("", "home_page",
"verse_of_the_day_activate", ...))) {

should work.

Regards,

Jonathan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Array

am 10.08.2009 14:35:51 von Robert Cummings

Ron Piggott wrote:
> How do I change this ELSEIF into an array?
>
> } elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> "verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page <> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( $page <> "resource_center" ) AND ( $page <> "network" ) ) {

Put all the compared values into an array, then check that $page is not
in_array().

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Array

am 10.08.2009 17:29:17 von List Manager

Ron Piggott wrote:
> How do I change this ELSEIF into an array?
>
> } elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> "verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page <> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( $page <> "resource_center" ) AND ( $page <> "network" ) ) {


$d = array(
"home_page",
"member_services",
"member_services_login",
"network",
"resource_center",
"verse_of_the_day_activate",
);

} elseif ( !empty($page) && in_array($page, $d) ) {

?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Array

am 10.08.2009 17:43:23 von Colin Guthrie

'Twas brillig, and Jim Lucas at 10/08/09 16:29 did gyre and gimble:
> $d = array(
> "home_page",
> "member_services",
> "member_services_login",
> "network",
> "resource_center",
> "verse_of_the_day_activate",
> );

Ahh someone else who always puts a closing , on the end of array
definitions to cut down on VCS diff/patch churn. Excellent :)

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Array

am 10.08.2009 18:00:59 von Robert Cummings

Colin Guthrie wrote:
> 'Twas brillig, and Jim Lucas at 10/08/09 16:29 did gyre and gimble:
>> $d = array(
>> "home_page",
>> "member_services",
>> "member_services_login",
>> "network",
>> "resource_center",
>> "verse_of_the_day_activate",
>> );
>
> Ahh someone else who always puts a closing , on the end of array
> definitions to cut down on VCS diff/patch churn. Excellent :)

I do it too since it makes life simple when commenting in and out chunks
of code.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Array

am 10.08.2009 23:42:07 von List Manager

Robert Cummings wrote:
> Colin Guthrie wrote:
>> 'Twas brillig, and Jim Lucas at 10/08/09 16:29 did gyre and gimble:
>>> $d = array(
>>> "home_page",
>>> "member_services",
>>> "member_services_login",
>>> "network",
>>> "resource_center",
>>> "verse_of_the_day_activate",
>>> );
>>
>> Ahh someone else who always puts a closing , on the end of array
>> definitions to cut down on VCS diff/patch churn. Excellent :)
>
> I do it too since it makes life simple when commenting in and out chunks
> of code.
>
> Cheers,
> Rob.

Yes, it does make life a little easier!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php