Hello,

I have a problem to get unique values from dateperiod-loop.

There is a tons of examples how to do it, but after hours of searching, i couldn't find suitable solution for me.
The code starts like this. To put it into array_unigue is hard to accomplish for me.

Have you any simple proposals to make it working?

$intrvl =  strtotime("1970-01-01 00:30:00 UTC");

$dateTimes = new DatePeriod(
new DateTime($starttime),
new DateInterval('PT'.$intrvl.'S'),
new DateTime($endtime)
);

foreach ($dateTimes as $dt) {

    $start=$dt->format('H.i');
    $end=date('H.i',strtotime('+30 minutes',strtotime($start)));

    echo'<div>'.$start.' - '.$end.'</div>';

}

Hi,
From that loop, only unique values for $start.

-matti

So I dropped your code as-is on http://phpfiddle.org and has issues that stopped me from seeing what it does.

Now that I tried that, you'll have to explain in detail what you need. Consider this as if you are outsourcing a project and detail it enough that others can write the function.

Or fix your code to run on http://phpfiddle.org

I also have no idea what you want. Rather than talk about your attempt at solving the problem, explain to us the big picture of what you are doing,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.