Julian Posted May 2, 2008 Share Posted May 2, 2008 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 More sharing options...
Rohan Shenoy Posted May 2, 2008 Share Posted May 2, 2008 Use the array_unique() function to output only the unique values in an array Link to comment https://forums.phpfreaks.com/topic/103930-solved-limit-an-array/#findComment-532054 Share on other sites More sharing options...
rondog Posted May 2, 2008 Share Posted May 2, 2008 <?php $ar = array(1,2,3,2,3,1,2,3); $unique = array_unique($ar); print_r($unique); ?> beat me to it! hah Link to comment https://forums.phpfreaks.com/topic/103930-solved-limit-an-array/#findComment-532061 Share on other sites More sharing options...
Julian Posted May 2, 2008 Author Share Posted May 2, 2008 Thanks guys Just what I've been looking for. Regards Julian Link to comment https://forums.phpfreaks.com/topic/103930-solved-limit-an-array/#findComment-532076 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.