<?php $arr = Array ( '2018-10-18' => 5, '2018-10-19' => 5, '2018-10-20' => 5, '2018-10-27' => 5, '2018-10-28' => 4, '2018-10-29' => 4, '2018-11-03' => 4 ); Foreach(array_unique($arr) as $v){ $temp = array_keys(array_intersect($arr, [$v])); $new[] = ['start' => current($temp), 'end' => end($temp), 'value' => $v]; } var_dump($new);
You have javascript disabled. You will not be able to edit any code.