Jump to content

[SOLVED] Limit an array


Julian

Recommended Posts

Hi guys

 

I have this array:

while ($row_calendar = mysql_fetch_assoc($calendar)){
	$sd = $row_calendar['inicio'];
	$ed = $row_calendar['termino'];
	for ($z=strtotime($sd);$z<=strtotime($ed);$z+=86400){
	$dia[] = date('j',$z); }
} 

foreach($dia as $value){
$c++;
     	$d = $value;
        $l = 'users2.php?dia='.$d.'&mes='.$mes.'&ano='.$anio;
$dias[$d][] = $l;
}

 

It works fine but I need to output only 1 record per day.  With this script I output all the records in the array.  Is there any way I can print only the arrays that are different? (Example now it outputs (1,2,3,2,3,1,2,3)  I want ot output only (1,2,3)).

 

Try to do this from the mysql query but no luck, I think should be easier from the script. 

 

Thanks for looking.

 

Regards

 

 

Julian

Link to comment
https://forums.phpfreaks.com/topic/103930-solved-limit-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.