Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/03/2011, 11:26
ben_mx
 
Fecha de Ingreso: marzo-2011
Mensajes: 5
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: mostrar horas faltantes de array y pintar tabla

si mira gracias por contestarme hasta ahorita estioy construyendola asi pero se me siguen repitiendo datos para ser preciso el ultimo de de los rangos faltantes

asi

08:00:00

8:30:00 - 08:45:00
no deberia mostrarse->8:45:00 - 09:00:00

08:45:00

9:15:00 - 09:30:00
9:30:00 - 09:45:00

aqui abajo estan las funciones que uso

Código PHP:
 $this->celda('08:00:00','08:15:00',$myArray); 
y la función celda es esta

Código PHP:

function celda($hora_a_comparar1,$hora_a_comparar2,$arreglo){


$rangos=$this->create_time_range($hora_a_comparar1,$hora_a_comparar2,'15 mins');
    
foreach (
$rangos as $key => $time)
    
$hora_perdidas='<li>'.date('g:i:s'$time).' - '.$this->minDespues(date('g:i:s'
$time)).'</li>';    

if( (
$this->in_array_recursive($hora_a_comparar1,$arreglo)>0) ){
    
        echo 
'<strong style="color:#08c">'.$hora_a_comparar1.'</strong>';
        
        }else{
            
            
            if(
$hora_a_comparar1==$hora_perdidas){
            echo 
'';
            }else{
            
            echo 
$hora_perdidas;
            }
            }


funcion in_array_recursive:

Código PHP:
function in_array_recursive($needle$haystack) {

    
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack));

    foreach(
$it as $element) {
        if(
$element == $needle) {
            return 
true;
        }
    }

    return 
false;

Código PHP:
function create_time_range($start$end$by='15 mins') {

    
$start_time strtotime($start);
    
$end_time   strtotime($end);

    
$current    time();
    
$add_time   strtotime('+'.$by$current);
    
$diff       $add_time-$current;

    
$times = array();
    while (
$start_time $end_time) {
        
$times[] = $start_time;
        
$start_time += $diff;
    }
    
$times[] = $start_time;
    return 
$times;

si me pudieras hechas una mano seria excelente, ya casi esta, pero este detalle me detiene aun, gracias de antemano.