<?php
$arr = [
"01/02/2015",
"02/02/2015",
"03/02/2015",
"04/02/2015",
"05/02/2015",
"09/02/2015",
"10/02/2015",
"11/02/2015",
"12/02/2015",
];
//complexidade O(n)
function processaDias($arrDias) {
$index = 0;
$dia_anterior = "";
$ret = [];
foreach($arrDias as $dia) {
if ($dia_anterior === "") {
$ret[$index][] = $dia;
$dia_anterior = $dia;
continue;
}
$d1 = DateTime::createFromFormat("d/m/Y", $dia_anterior);
$d2 = DateTime::createFromFormat("d/m/Y", $dia);
$diff = $d2->diff($d1);
if($diff->format("%d") !== "1") {
$index++;
}
$ret[$index][] = $dia;
$dia_anterior = $dia;
}
return $ret;
}
$res = processaDias($arr);
PD9waHAKCiRhcnIgPSBbCgkiMDEvMDIvMjAxNSIsCgkiMDIvMDIvMjAxNSIsCgkiMDMvMDIvMjAxNSIsCgkiMDQvMDIvMjAxNSIsCgkiMDUvMDIvMjAxNSIsCgkiMDkvMDIvMjAxNSIsCgkiMTAvMDIvMjAxNSIsCgkiMTEvMDIvMjAxNSIsCgkiMTIvMDIvMjAxNSIsCl07CgovL2NvbXBsZXhpZGFkZSBPKG4pCmZ1bmN0aW9uIHByb2Nlc3NhRGlhcygkYXJyRGlhcykgewoJJGluZGV4ID0gMDsKCSRkaWFfYW50ZXJpb3IgPSAiIjsKCSRyZXQgPSBbXTsKCWZvcmVhY2goJGFyckRpYXMgYXMgJGRpYSkgewoJCWlmICgkZGlhX2FudGVyaW9yID09PSAiIikgewoJCQkkcmV0WyRpbmRleF1bXSA9ICRkaWE7CgkJCSRkaWFfYW50ZXJpb3IgPSAkZGlhOwoJCQljb250aW51ZTsKCQl9CgkJCgkJJGQxID0gRGF0ZVRpbWU6OmNyZWF0ZUZyb21Gb3JtYXQoImQvbS9ZIiwgJGRpYV9hbnRlcmlvcik7CgkJJGQyID0gRGF0ZVRpbWU6OmNyZWF0ZUZyb21Gb3JtYXQoImQvbS9ZIiwgJGRpYSk7CgkJCgkJJGRpZmYgPSAkZDItPmRpZmYoJGQxKTsKCQoJCWlmKCRkaWZmLT5mb3JtYXQoIiVkIikgIT09ICIxIikgewoJCQkkaW5kZXgrKzsKCQl9CgkJCgkJJHJldFskaW5kZXhdW10gPSAkZGlhOwoJCQoJCSRkaWFfYW50ZXJpb3IgPSAkZGlhOwoJfQoJCglyZXR1cm4gJHJldDsKfQoKJHJlcyA9IHByb2Nlc3NhRGlhcygkYXJyKTsKCnZhcl9kdW1wKCRyZXMpOw==