[olug] crazy php stuff
Sam Tetherow
tetherow at nicusa.com
Thu Aug 7 20:31:27 UTC 2003
quote your associative keys otherwise it is an array so the keys are
taken as number values in which case 08 is assumed octal (which is not
valid). You will notice that 9 is wrong as well.
Brian Roberson wrote:
> Thought I would pass this along to the other php'ers here..
>
> So I whipped up this php thing a while ago.. anyways I had an array of k->v
> pairs and I was using a foreach to walk through it, one k->v always gets
> missed/messed up... not in the middle,start, or end, basically it is a date
> padding feature... here is a snippit:
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> echo "<SELECT NAME=DAY>";
> $DD = array(
> 01 => 1,
> 02 => 2,
> 03 => 3,
> 04 => 4,
> 05 => 5,
> 06 => 6,
> 07 => 7,
> 08 => 8,
> 09 => 9,
> 10 => 10,
> 11 => 11,
> 12 => 12,
> 13 => 13,
> 14 => 14,
> 15 => 15,
> 16 => 16,
> 17 => 17,
> 18 => 18,
> 19 => 19,
> 20 => 20,
> 21 => 21,
> 22 => 22,
> 23 => 23,
> 24 => 24,
> 25 => 25,
> 26 => 26,
> 27 => 27,
> 28 => 28,
> 29 => 29,
> 30 => 30,
> 31 => 31,
> );
> foreach ($DD as $dr => $dd) {
> $DAY = date("d");
> if ($DAY == $dr) { $SEL = " SELECTED "; } else { $SEL = ""; }
> echo "<OPTION VALUE=$dr$SEL>$dd\n";
> }
> echo "
> </SELECT>
> ";
>
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> pretty basic eh? -- anyways.... the 8th element ALWAYS gets munged ( give it
> a try, I used 3 different php vers, all above 4.1.
>
>
> anyone have any ideas what the heck is happenening --- In ANY event I got
> around it, in alot less lines of code, so for the intrigued, here is my
> solution....
>
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> for( $i=1;$i <= 31;$i++ )
> {
> $DAY = date("d");
> if ($DAY == $i) { $SEL = " SELECTED "; } else { $SEL = ""; }
> printf( "\t<OPTION VALUE=%02d $SEL>$i\n", $i );
> }
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>
>
> It still bugs the crap out of me why it skips an element, so if anyone has
> an idea, pas it along!!
>
>
>
>
>
>
>
>
>
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
>
--
------------------------------------------------------------------------
Sam Tetherow tetherow at nicusa.com
Director of Development
NIC Labs (PSSG) http://www.nicusa.com
More information about the OLUG
mailing list