Click to See Complete Forum and Search --> : [RESOLVED] dynamic array
niladhar8@gmail.com
May 17th, 2011, 12:47 PM
i have values stored in an array with key
$array['total']['2001-11-09'];
the year month and day are as separate variables, how can i print its content out. I tried all below
$temp = $year."-".$month."-".$day;
echo $array['total'][$temp];
echo $array['total'][."'".$temp."'"];
none work.
PeejAvery
May 17th, 2011, 01:00 PM
Your first echo is correct. If it's not returning a value...then you have your key incorrect. I'd suggest echoing the $temp as well to make sure.
niladhar8@gmail.com
May 17th, 2011, 01:03 PM
Your first echo is correct. If it's not returning a value...then you have your key incorrect. I'd suggest echoing the $temp as well to make sure.
yes i did echo my temp, and my source array as well.
the source array has this
$date['total'][2011-01-09] = 60.00;
echo $temp; // 2011-01-09;
niladhar8@gmail.com
May 17th, 2011, 01:07 PM
yes i did echo my temp, and my source array as well.
the source array has this
$date['total'][2011-01-09] = 60.00;
echo $temp; // 2011-01-09;
i think i know what it is.... my array has 2011-01-09 as the key..... in my loop inside the calender where i try and display the amount for that date, it calculates to 2011-01-9 leaving out the 0.
anywork around this.
niladhar8@gmail.com
May 17th, 2011, 01:11 PM
i think i know what it is.... My array has 2011-01-09 as the key..... In my loop inside the calender where i try and display the amount for that date, it calculates to 2011-01-9 leaving out the 0.
Anywork around this.
resolved
PeejAvery
May 17th, 2011, 01:14 PM
For the sake of others...always share how it was resolved, and mark the thread resolved from in the Thread Tools menu.
I'm assuming you used sprintf().
niladhar8@gmail.com
May 17th, 2011, 01:26 PM
For the sake of others...always share how it was resolved, and mark the thread resolved from in the Thread Tools menu.
I'm assuming you used sprintf().
how would i accomplish it using sprintf(); right now i used ternary operator to check if less than 10 and added 0 in front.
sorry bout that, will share it next time, i knew my work around was not clean code..... and did not know resolved was in that menu. will keep that in mind.
PeejAvery
May 17th, 2011, 01:33 PM
sprintf("%02d", $year);
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.