<?php

function fn_and_ll($aql)
{
	$data = $aql->Consume(2);
	$framea = $data[0]->value;
	$frameb = $data[1]->value;
	$final = array();
		
	foreach($framea as $a)
	{		
		foreach($frameb as $b)
		{
			if ($a['from'] <= $b['to'] and $b['from'] < $a['to'])
			{
				/*echo 'Found A Match Between ';
				print_r($a);
				echo ' and ';
				print_r($b);*/
				
                $st = $a['from'];
                $en = $b['to'];
                if ($a['to'] < $b['to'])
				{
                    $en = $a['to'];
				}
                if ($b['from'] > $a['from'])
				{
                    $st = $b['from'];
				}
				$nw = array();
				$nw['from'] = $st;
				$nw['to'] = $en;
                $final[] = $nw;
			}
		}
	}
	
	$a = new AQLStackElement();
	$a->typename = "timelist";
	$a->islist = true;
	$a->value = $final;
	array_push($aql->stack,$a);
}
?>