If either one of both equals

Posted by user1620028 on Stack Overflow See other posts from Stack Overflow or by user1620028
Published on 2012-10-04T21:31:37Z Indexed on 2012/10/04 21:37 UTC
Read the original article Hit count: 164

I have start and end dates which are stored in a database in this format:

start date= 20121004     //4th October 2012
end date= 20121004     //16th November 2012

so I can use date format:

$date = date("Ymd"); // returns: 20121004

to determine when to display and not display

to repopulate my update input boxes I use:

$start=(str_split($stdate,4));// START DATE: splits stored date into 2x4 ie: 20121209 = 2012 1209
$syr =  $start[0];// re first half ie: 2012 which is the year
$start2 = $start[1];//re second half ie: 1209
$start3=(str_split($start2,2));// splits second half date into 2x2 ie: 1209 = 12 09
$smth = $start3[0]; // first half = month ie: 12
$sday = $start3[1];  // second half = day ie: 09
$expiry=(str_split($exdate,4)); ///SAME AGAIN FOR EXPIRY DATE ...
$xyr =  $expiry[0];
$expiry2 = $expiry[1];
$expiry3=(str_split($expiry2,2));
$xmth = $expiry3[0]; 
$xday = $expiry3[1];

which works fine but I need to repopulate the input boxes for the month showing the date in the database like this

<option value="01">January</option`>

using

if ($smth==01):$month='January'; endif;
if ($xmth==01):$month='January'; endif;
// if the start and/or expiry month number = 01 display $month as January
if ($smth==02):$smonth='February'; endif;
if ($xmth==02):$smonth='February'; endif;
if ($smth==03):$month='March'; endif;

<select name="stmonth" class="input">
<option value="<?=$smth?>"><?=$month?></option>
...
</select>

is there an easier way to display IF EITHER ONE EQUALS rather than having to write the same line twice once for each $smth AND $xmth ? re: if ($smth **and or** $xmth ==01):$month='January'; endif;

© Stack Overflow or respective owner

Related posts about php

Related posts about date