| Author |
Message |
Desbrina Jadeite

Joined: 11 Jun 2005 Posts: 3008 Location: Earth
|
Posted: Thu Oct 25, 2007 10:36 am Post subject: php if statement |
|
|
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
|
Posted: Thu Oct 25, 2007 11:05 pm Post subject: Re: php if statement |
|
|
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
|
|
| Back to top |
|
| |
LP-SolidRaven Dictator of the Dump

Joined: 06 Jun 2004 Posts: 7297 Location: The cheese is made out of moon
|
Posted: Fri Oct 26, 2007 10:46 am Post subject: |
|
|
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  _________________
| 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
|
Posted: Sat Oct 27, 2007 5:59 pm Post subject: |
|
|
| 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  |
The regex also makes the code easier to maintain.  _________________ 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
|
Posted: Sun Oct 28, 2007 2:56 am Post subject: |
|
|
| 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  |
The regex also makes the code easier to maintain.  |
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
|
Posted: Sun Nov 11, 2007 5:00 am Post subject: Re: php if statement |
|
|
| 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 |
|
| |
|
|
|