[PHP] Re: Appending to an Array

2007-06-16 Thread Vlad Vlasceanu

. is the concatenation operator, usually applies only to strings

try:
$days[] = array($this_day=array(#,today-day));

or actually:
$days[$this_day] = array(#,today-day);

since it looks like you're indexing based on the day


Keith Spiller wrote:

Hi Folks,

RE:  Appending to an Array

Here is my code:

 # PREVIOUS MONTH 
-

   $days = array(
   10=array(/weblog/archive/2004/Jan/02,linked-day),
   12=array(/weblog/archive/2004/Jan/03,linked-day),
   25=array(/weblog/archive/2004/Jan/08,linked-day));
   phpcalendar($year, $month-1, $days, $month_href);
 # 
 



 # CURRENT MONTH 
--

   $days = array(
   2=array(/weblog/archive/2004/Jan/02,linked-day),
   3=array(/weblog/archive/2004/Jan/03,linked-day),
   8=array(/weblog/archive/2004/Jan/08,linked-day),
   22=array(/weblog/archive/2004/Jan/22,linked-day));
   phpcalendar($year, $month, $days, $month_href);
 # 
 



 # NEXT MONTH 
-

   $days = array(
   17=array(/weblog/archive/2004/Jan/02,linked-day),
   18=array(/weblog/archive/2004/Jan/03,linked-day),
   19=array(/weblog/archive/2004/Jan/08,linked-day));
   phpcalendar($year, $month+1, $days, $month_href);
 # 
 




function phpcalendar($year, $month, $days, $month_href) {

 $weekday_lth = 1;

 # TODAY 
--

   $this_day = date('j',time());
   $this_month = date('n', time());
   $this_year = date('Y', time());
   $month_href = ?year=$yearmonth=$month;
   $days .= array($this_day=array(#,today-day));
 # 
 



 echo div class=\divfloat\;
 echo generate_calendar($year, $month, $days, $weekday_lth, $month_href);
 echo /div;
}


My problem is with the 7th line from the end:
   $days .= array($this_day=array(#,today-day));

I want to append these values to the $days array (if the month, day and 
year match)
but this technique causes a parse error.  Any ideas?  Thanks for your 
help...



Keith


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Appending to an Array

2007-06-16 Thread Keith Spiller
Awesome Vlad.  You fixed it with your second example perfectly!  Thank you 
so much.


Keith

- Original Message - 
From: Vlad Vlasceanu [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Saturday, June 16, 2007 10:43 PM
Subject: [PHP] Re: Appending to an Array



. is the concatenation operator, usually applies only to strings

try:
$days[] = array($this_day=array(#,today-day));

or actually:
$days[$this_day] = array(#,today-day);

since it looks like you're indexing based on the day


Keith Spiller wrote:

Hi Folks,

RE:  Appending to an Array

Here is my code:

 # PREVIOUS 
MONTH -

   $days = array(
   10=array(/weblog/archive/2004/Jan/02,linked-day),
   12=array(/weblog/archive/2004/Jan/03,linked-day),
   25=array(/weblog/archive/2004/Jan/08,linked-day));
   phpcalendar($year, $month-1, $days, $month_href);
 # 


 # CURRENT 
MONTH --

   $days = array(
   2=array(/weblog/archive/2004/Jan/02,linked-day),
   3=array(/weblog/archive/2004/Jan/03,linked-day),
   8=array(/weblog/archive/2004/Jan/08,linked-day),
   22=array(/weblog/archive/2004/Jan/22,linked-day));
   phpcalendar($year, $month, $days, $month_href);
 # 


 # NEXT 
MONTH -

   $days = array(
   17=array(/weblog/archive/2004/Jan/02,linked-day),
   18=array(/weblog/archive/2004/Jan/03,linked-day),
   19=array(/weblog/archive/2004/Jan/08,linked-day));
   phpcalendar($year, $month+1, $days, $month_href);
 # 



function phpcalendar($year, $month, $days, $month_href) {

 $weekday_lth = 1;

 # 
TODAY --

   $this_day = date('j',time());
   $this_month = date('n', time());
   $this_year = date('Y', time());
   $month_href = ?year=$yearmonth=$month;
   $days .= array($this_day=array(#,today-day));
 # 


 echo div class=\divfloat\;
 echo generate_calendar($year, $month, $days, $weekday_lth, $month_href);
 echo /div;
}


My problem is with the 7th line from the end:
   $days .= array($this_day=array(#,today-day));

I want to append these values to the $days array (if the month, day and 
year match)
but this technique causes a parse error.  Any ideas?  Thanks for your 
help...



Keith


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php