Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

php if statement

 
Lifelesspeople.com Forum Index -> Web Architects' Abode
Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
Desbrina
Jadeite


Joined: 11 Jun 2005
Posts: 3008
Location: Earth

PostPosted: Thu Oct 25, 2007 10:36 am    Post subject: php if statement Reply with quote

I'm currently using this code which is working fine, i don't have any problem with it

Code:
if (in_array($_GET['deck'], array('ja01', 'ja02', 'ja03', 'ja04', 'ja05', 'ja06', 'ja07', 'ja08', 'ja09', 'ja10', 'ja11', 'ja12', 'ja13', 'ja14', 'ja15', 'ja16', 'ja18', 'ja18', 'jase1', 'jase2')))
    define('CARDS_PER_ROW', 3);
else
    define('CARDS_PER_ROW', 5);


But i'm wondering if theres any way to cut down on the ja01-18, if there's a way to put it in as ja01-18 or similar as it takes up a lot of space
_________________
Midnight Tempest - A Sailor Moon TCG
Balanced Force - A Star Wars TCG
Caretaker - A Star Trek Voyager TCG
My Stories
Back to top
 
exsanguination
Forum Regular


Joined: 27 Apr 2005
Posts: 418
Location: Australia

PostPosted: Thu Oct 25, 2007 11:05 pm    Post subject: Re: php if statement Reply with quote

you could write a regex

Code:

preg_match("/ja(0[1-9]|1[0-8])|jase[1-2]/", $_GET['deck'])


or something like that. I haven't tested it with PHP, but I think the syntax is basically that....
Back to top
 
Desbrina
Jadeite


Joined: 11 Jun 2005
Posts: 3008
Location: Earth

PostPosted: Fri Oct 26, 2007 4:09 am    Post subject: Reply with quote

thanks, works fine
_________________
Midnight Tempest - A Sailor Moon TCG
Balanced Force - A Star Wars TCG
Caretaker - A Star Trek Voyager TCG
My Stories
Back to top
 
LP-SolidRaven
Dictator of the Dump


Joined: 06 Jun 2004
Posts: 7297
Location: The cheese is made out of moon

PostPosted: Fri Oct 26, 2007 10:46 am    Post subject: Reply with quote

The first code you posted has a good performance.
The second one might add a really small bit to execution time. But since that doesn't matter in your case, use the regex code Smile
_________________
Quote:

<bart416> I just realized something
<bart416> we celebrate the fact that this piece of rock made one rotation around a glowing ball of plasma that is kept together due to its own gravity well
<njsg> HAPPY NEW YEAR
<Easter> ^^
Back to top
 
ClickFanatic
Est. 2005


Joined: 18 Jan 2005
Posts: 4100
Location: A particular geographic area

PostPosted: Sat Oct 27, 2007 5:59 pm    Post subject: Reply with quote

SolidRaven wrote:
The first code you posted has a good performance.
The second one might add a really small bit to execution time. But since that doesn't matter in your case, use the regex code Smile

The regex also makes the code easier to maintain. Wink
_________________
Captain Jell-O Buster from the Future
[img]http://feeds.feedburner.com/sparepencil.1.gif[/img]
Back to top
 
LP-SolidRaven
Dictator of the Dump


Joined: 06 Jun 2004
Posts: 7297
Location: The cheese is made out of moon

PostPosted: Sun Oct 28, 2007 2:56 am    Post subject: Reply with quote

ClickFanatic wrote:
SolidRaven wrote:
The first code you posted has a good performance.
The second one might add a really small bit to execution time. But since that doesn't matter in your case, use the regex code Smile

The regex also makes the code easier to maintain. Wink

True, assuming you know the perl regex patterns.
_________________
Quote:

<bart416> I just realized something
<bart416> we celebrate the fact that this piece of rock made one rotation around a glowing ball of plasma that is kept together due to its own gravity well
<njsg> HAPPY NEW YEAR
<Easter> ^^
Back to top
 
flaming-ace
Experienced Poster


Joined: 28 Aug 2007
Posts: 59


PostPosted: Sun Nov 11, 2007 5:00 am    Post subject: Re: php if statement Reply with quote

exsanguination wrote:
you could write a regex

Code:

preg_match("/ja(0[1-9]|1[0-8])|jase[1-2]/", $_GET['deck'])


or something like that. I haven't tested it with PHP, but I think the syntax is basically that....

that helped me out to thanks, i needed somthing like this a while back
_________________
[img:0692e75ce3]http://img507.imageshack.us/img507/7623/flamingacesiguy7.jpg[/img:0692e75ce3]
Click Here
Back to top
 
Display posts from previous:   
Post new topic   Reply to topic    Lifelesspeople.com Forum Index -> Web Architects' Abode All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com