Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/02/2010, 10:37
juan007
 
Fecha de Ingreso: marzo-2004
Ubicación: Chile
Mensajes: 382
Antigüedad: 20 años, 1 mes
Puntos: 0
Respuesta: array_key_exists ó in_array

haber lo que pasa que yo genero el calendario con un for de esta forma.

Código PHP:
for($i=0$i$total_rows$i++)
            {
                for(
$j=0$j<7;$j++)
                {
                    
$day++;                    

                    if(
$day>&& $day<=$total_days_of_current_month)
                    {
                        
//YYYY-MM-DD date format
                        
$date_form "$current_year/$current_month/$day";

                        echo 
'<td';

                        
//check if the date is today
                        
if($date_form == $today){
                            echo 
' class="today"';
                        }

                        
//check if any event stored for this date in $events array
                        
if(array_key_exists("day",$events)){
                         
// if (in_array($day, $events)){
                            //adding the date_has_event class to the <td> and close it
                            
echo ' class="date_has_event"> '.$day;
                            
                            
//adding the eventTitle and eventContent wrapped with <span> and <li> to <ul>
                            
echo '<div class="events">
                                        <ul>'
.$events[$day].'</ul>
                                    </div>'
;
                        }
                        else
                        {
                            
//if there is not event on that date then just close the <td> tag
                            
echo '> '.$day;
                        }

                        echo 
"</td>";
                    }
                    else
                    {
                        
//showing empty cells in the first and last row
                        
echo '<td class="padding">&nbsp;</td>';
                    }
                }
                echo 
"</tr><tr>";
            }
            
            
?> 
ese es el codigo que ocupa si te das cuenta hay comentario donde hice mis pruebas // if (in_array($day, $events)){ ...

Pero por ejemplo si me pinta el dia actual que este trozo de codigo.

Código PHP:
//check if the date is today
    
if($date_form == $today){
        echo 
' class="today"';
    } 
y si le asigno la clase today a los dias con eventos tampoco hace nada....entonces segun esas pruebas debe ser algo con php y los arreglos...gracias por tu interes en ayudarme.