PHP создает информацию о бронировании из массива с различными приоритетами и временными диапазонами на дату, которая не может перекрываться

У меня есть следующий массив PHP:

Array
(
[20170118] => Array
(
[1420] => Array
(
[ENDDATE] => 2017-01-18
[STARTTIME] => 1420
[ENDTIME] => 1530
[PRIORITY] => superadmin
[PRESENTATION] => 46203
[TITLE] => Ny+video+test
)

[0800] => Array
(
[ENDDATE] => 2017-01-18
[STARTTIME] => 0800
[ENDTIME] => 1000
[PRIORITY] => superadmin
[PRESENTATION] => 09341
[TITLE] => Linket+pr%C3%A6sentationer+2
)

[1200] => Array
(
[ENDDATE] => 2017-01-18
[STARTTIME] => 1200
[ENDTIME] => 1500
[PRIORITY] => high
[PRESENTATION] => 28160
[TITLE] => Linket+pr%C3%A6sentationer
)

[1600] => Array
(
[ENDDATE] => 2017-01-18
[STARTTIME] => 1600
[ENDTIME] => 1800
[PRIORITY] => high
[PRESENTATION] => 95042
[TITLE] => Pausesk%C3%A6rm
)

[0700] => Array
(
[ENDDATE] => 2017-01-18
[STARTTIME] => 0700
[ENDTIME] => 1130
[PRIORITY] => high
[PRESENTATION] => 65921
[TITLE] => Linket+Linket+pr%C3%A6sentationer+1
)

[1100] => Array
(
[ENDDATE] => 2017-01-18
[STARTTIME] => 1100
[ENDTIME] => 2100
[PRIORITY] => normal
[PRESENTATION] => 85643
[TITLE] => Kalender
)
)
)

что мне нужно сделать с этим массивом, так это то, что он должен создать новый массив, содержащий эти элементы, но время начала и окончания не перекрывают друг друга
(супер-админ имеет самый высокий приоритет, а обычный — самый низкий).
— Супер администратор должен быть всегда.
— Высокий должен быть там во всю длину, если он не перекрывает супер администратора.
нормальное должно быть только в том случае, если они не перекрывают другие приоритеты.

Новый массив должен выглядеть так:

Array
(
[20170118] => Array
(
[0700] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 0700
[ENDTIME] => 0800
[PRIORITY] => high
[PRESENTATION] => 65921
[TITLE] => Linket+Linket+pr%C3%A6sentationer+1
)

[0800] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 0800
[ENDTIME] => 1000
[PRIORITY] => superadmin
[PRESENTATION] => 09341
[TITLE] => Linket+pr%C3%A6sentationer+2
)

[1000] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1000
[ENDTIME] => 1130
[PRIORITY] => high
[PRESENTATION] => 65921
[TITLE] => Linket+Linket+pr%C3%A6sentationer+1
)

[1130] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1130
[ENDTIME] => 1200
[PRIORITY] => normal
[PRESENTATION] => 85643
[TITLE] => Kalender
)

[1200] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1200
[ENDTIME] => 1420
[PRIORITY] => high
[PRESENTATION] => 28160
[TITLE] => Linket+pr%C3%A6sentationer
)

[1420] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1420
[ENDTIME] => 1530
[PRIORITY] => superadmin
[PRESENTATION] => 46203
[TITLE] => Ny+video+test
)

[1530] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1530
[ENDTIME] => 1600
[PRIORITY] => normal
[PRESENTATION] => 85643
[TITLE] => Kalender
)

[1600] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1600
[ENDTIME] => 1800
[PRIORITY] => high
[PRESENTATION] => 95042
[TITLE] => Pausesk%C3%A6rm
)

[1800] => Array
(
[ENDDATE] => 2017-01-18
[STARTIME] => 1800
[ENDTIME] => 2100
[PRIORITY] => normal
[PRESENTATION] => 85643
[TITLE] => Kalender
)
)
)

0

Решение

Я сам разобрался с этой частью с помощью классов в php, возможно, я не был бы правильным способом сделать это. но по крайней мере он выводит то, что я хотел, вот что я сделал:

<?php
/*
This JSON encoded away contains the elements wich have been booked for each day, wich start and end time of the day
priority order is:
Normal: is the lowest priority
High: is always more important than normal
Superadmin: Is the highest priority and should always be shown over the other priorities
*/
$array = '{"20170118":{"superadmin":[{"ENDDATE":"2017-01-18","STARTTIME":"1420","ENDTIME":"1530","PRIORITY":"superadmin","PRESENTATION":"46203","TITLE":"Ny+video+test"},{"ENDDATE":"2017-01-18","STARTTIME":"0800","ENDTIME":"1000","PRIORITY":"superadmin","PRESENTATION":"09341","TITLE":"Linket+pr%C3%A6sentationer+2"}],"high":[{"ENDDATE":"2017-01-18","STARTTIME":"1200","ENDTIME":"1500","PRIORITY":"high","PRESENTATION":"28160","TITLE":"Linket+pr%C3%A6sentationer"},{"ENDDATE":"2017-01-18","STARTTIME":"1600","ENDTIME":"1800","PRIORITY":"high","PRESENTATION":"95042","TITLE":"Pausesk%C3%A6rm"},{"ENDDATE":"2017-01-18","STARTTIME":"0700","ENDTIME":"1130","PRIORITY":"high","PRESENTATION":"65921","TITLE":"Linket+Linket+pr%C3%A6sentationer+1"}],"normal":[{"ENDDATE":"2017-01-18","STARTTIME":"1100","ENDTIME":"2100","PRIORITY":"normal","PRESENTATION":"85643","TITLE":"Kalender"}]},"20170119":{"superadmin":[{"ENDDATE":"2017-01-19","STARTTIME":"0000","ENDTIME":"0629","PRIORITY":"superadmin","PRESENTATION":"46203","TITLE":"Ny+video+test"}],"high":[{"ENDDATE":"2017-01-19","STARTTIME":"0527","ENDTIME":"1427","PRIORITY":"high","PRESENTATION":"85643","TITLE":"Kalender"}],"normal":[{"ENDDATE":"2017-01-20","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170121":{"normal":[{"ENDDATE":"2017-01-22","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170123":{"normal":[{"ENDDATE":"2017-01-24","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170126":{"normal":[{"ENDDATE":"2017-01-27","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170128":{"normal":[{"ENDDATE":"2017-01-29","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170130":{"normal":[{"ENDDATE":"2017-01-31","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170202":{"normal":[{"ENDDATE":"2017-02-03","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170204":{"normal":[{"ENDDATE":"2017-02-05","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170206":{"normal":[{"ENDDATE":"2017-02-07","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170209":{"normal":[{"ENDDATE":"2017-02-10","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170211":{"normal":[{"ENDDATE":"2017-02-12","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170213":{"normal":[{"ENDDATE":"2017-02-14","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170216":{"normal":[{"ENDDATE":"2017-02-17","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170218":{"normal":[{"ENDDATE":"2017-02-19","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170220":{"normal":[{"ENDDATE":"2017-02-21","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170223":{"normal":[{"ENDDATE":"2017-02-24","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170225":{"normal":[{"ENDDATE":"2017-02-26","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170227":{"normal":[{"ENDDATE":"2017-02-28","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170302":{"normal":[{"ENDDATE":"2017-03-03","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170304":{"normal":[{"ENDDATE":"2017-03-05","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170306":{"normal":[{"ENDDATE":"2017-03-07","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170309":{"normal":[{"ENDDATE":"2017-03-10","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170311":{"normal":[{"ENDDATE":"2017-03-12","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170313":{"normal":[{"ENDDATE":"2017-03-14","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170316":{"normal":[{"ENDDATE":"2017-03-17","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170318":{"normal":[{"ENDDATE":"2017-03-19","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170320":{"normal":[{"ENDDATE":"2017-03-21","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170323":{"normal":[{"ENDDATE":"2017-03-24","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170325":{"normal":[{"ENDDATE":"2017-03-26","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170327":{"normal":[{"ENDDATE":"2017-03-28","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170330":{"normal":[{"ENDDATE":"2017-03-31","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170401":{"normal":[{"ENDDATE":"2017-04-02","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170403":{"normal":[{"ENDDATE":"2017-04-04","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170406":{"normal":[{"ENDDATE":"2017-04-07","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170408":{"normal":[{"ENDDATE":"2017-04-09","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170410":{"normal":[{"ENDDATE":"2017-04-11","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170413":{"normal":[{"ENDDATE":"2017-04-14","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170415":{"normal":[{"ENDDATE":"2017-04-16","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170417":{"normal":[{"ENDDATE":"2017-04-18","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170420":{"normal":[{"ENDDATE":"2017-04-21","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170422":{"normal":[{"ENDDATE":"2017-04-23","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170424":{"normal":[{"ENDDATE":"2017-04-25","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170427":{"normal":[{"ENDDATE":"2017-04-28","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170429":{"normal":[{"ENDDATE":"2017-04-30","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170501":{"normal":[{"ENDDATE":"2017-05-02","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170504":{"normal":[{"ENDDATE":"2017-05-05","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170506":{"normal":[{"ENDDATE":"2017-05-07","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170508":{"normal":[{"ENDDATE":"2017-05-09","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170511":{"normal":[{"ENDDATE":"2017-05-12","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170513":{"normal":[{"ENDDATE":"2017-05-14","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170515":{"normal":[{"ENDDATE":"2017-05-16","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170518":{"normal":[{"ENDDATE":"2017-05-19","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170520":{"normal":[{"ENDDATE":"2017-05-21","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170522":{"normal":[{"ENDDATE":"2017-05-23","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170525":{"normal":[{"ENDDATE":"2017-05-26","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170527":{"normal":[{"ENDDATE":"2017-05-28","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170529":{"normal":[{"ENDDATE":"2017-05-30","STARTTIME":"0000","ENDTIME":"0000","PRESENTATION":"95042","PRIORITY":"normal","TITLE":"Pausesk%C3%A6rm"}]},"20170116":{"normal":[{"ENDDATE":"2017-01-16","STARTTIME":"0000","ENDTIME":"0000","PRIORITY":"normal","PRESENTATION":"85643","TITLE":"Kalender"}]}}';
$json_decode = (array)json_decode($array, true);

class array_test_class{
private $_final_array   = array();
private $_priorities    = array("superadmin","high","normal");
private $_array         = array();

function __construct($arr=array()){
$this->_array = $arr;
}

/**
* sortByOrder function.
* sorts the array by STARTTIME parameter, so the lowest one always will be shown first in the array
*
* @access public
* @static
* @param mixed $a
* @param mixed $b
* @return void
*/
public static function sortByOrder($a, $b) {
return $a['STARTTIME'] - $b['STARTTIME'];
}

final function priorities(){
return $this->_priorities;
}

/**
* array_sort_final function.
* This function sort the array by using sortByOrder function
*
* @access public
* @final
* @param int $index (default: 0)
* @return void
*/
final function array_sort_final($index=0){
$new_tmp = array();
foreach($this->_array as $key => $test){
$tmp = $test;
usort($tmp, array('array_test_class','sortByOrder'));
$new_tmp[$key] = $tmp;
}
$this->_array = $new_tmp;
}

final function array_return(){
asort($this->_final_array);
return $this->_final_array;
}

/**
* array_create_conflicts_bookings function.
* If theres a conflict between current priorities and higher level priorities this part will make sure the lower prioritie is only active
* when theres a gap between the higher ones.
* eg. If a high priorite event is running from 08.00 - 14.15 and theres a normal running from 07.30 - 21.00 it will split the normal event up into:
* 07.30 - 08.00 (normal)
* 08.00 - 14.15 (high)
* 14.15 - 21.00 (normal)
*
* @access private
* @final
* @param mixed $_final_arr
* @param mixed $_a
* @param mixed $priority
* @return void
*/
private final function array_create_conflicts_bookings($_final_arr, $_a, $priority){
usort($_final_arr, array('array_test_class','sortByOrder'));
$_a_start_time  = $_a["STARTTIME"];
$_a_end_time    = $_a["ENDTIME"];

$i = 0;
foreach($_final_arr as $_f_arr){
$_f_start_time  = $_f_arr["STARTTIME"];
$_f_end_time    = $_f_arr["ENDTIME"];
$continue = false;

if($_a_start_time == $_a_end_time){
$_a_end_time = "2400";
}

if($_a_start_time < $_f_start_time){
if(!isset($this->_final_array[$_a_start_time])){
$this->_final_array[$_a_start_time] = array(
"ENDDATE"       => $_a["ENDDATE"],
"STARTTIME"     => $_a_start_time,
"ENDTIME"       => $_f_start_time,
"PRESENTATION"  => $_a["PRESENTATION"],
"TITLE"         => $_a["TITLE"],
"PRIORITY"      => $_a["PRIORITY"],
);
}
$_a_start_time = $_f_end_time;
}

if($_a_end_time >= $_f_end_time){
$_a_start_time = $_f_end_time;
if(!isset($this->_final_array[$_f_end_time])){
$end = $_a_end_time;
if(isset($_final_arr[$i+1])){
$end = $_final_arr[$i+1]["STARTTIME"];
}

$this->_final_array[$_f_end_time] = array(
"ENDDATE"       => $_a["ENDDATE"],
"STARTTIME"     => $_f_end_time,
"ENDTIME"       => ($end == "2400" ? "00000" : $end),
"PRESENTATION"  => $_a["PRESENTATION"],
"TITLE"         => $_a["TITLE"],
"PRIORITY"      => $_a["PRIORITY"],
);
}
}
$i++;
}
}

/**
* array_create_bookings function.
* This section creates the final array output and checks for conflicts, if theres a conflict the function array_create_conflicts_bookings will be run
*
* @access public
* @final
* @param int $priority (default: 0)
* @param bool $check_for_matches (default: false)
* @return void
*/
final function array_create_bookings($priority=0, $check_for_matches=false){
if($priority<3){
if(!$check_for_matches){
/* If its the first time we run the function it will always try to create the highest priority and run again in a loop and create next next priority events */
if(isset($this->_array[$this->_priorities[$priority]])){
foreach($this->_array[$this->_priorities[$priority]] as $_a){
$this->_final_array[$_a["STARTTIME"]] = array(
"ENDDATE"       => $_a["ENDDATE"],
"STARTTIME"     => $_a["STARTTIME"],
"ENDTIME"       => $_a["ENDTIME"],
"PRESENTATION"  => $_a["PRESENTATION"],
"TITLE"         => $_a["TITLE"],
"PRIORITY"      => $_a["PRIORITY"],
);
}
}
$this->array_create_bookings(($priority+1), true);
}else{
/* If its not the first run it will go down here and check for conflicts, if there is no conflict it will create the event else it will go to function array_create_conflicts_bookings */
if(isset($this->_array[$this->_priorities[$priority]])){
foreach($this->_array[$this->_priorities[$priority]] as $_a){
$_conflict = false;
$_conflicting_array = array();
foreach($this->_final_array as $_final_key => $_final_arr){
$tmp_end = $_a['ENDTIME'];
if($_a['ENDTIME'] == "0000"){
$tmp_end = "2400";
}
if (($_final_arr['STARTTIME'] <= $tmp_end) && ($_final_arr['ENDTIME'] >= $_a['STARTTIME'])) {
$_conflicting_array[] = $_final_arr;
$_conflict = true;
}
}
if($_conflict){
$this->array_create_conflicts_bookings($_conflicting_array, $_a, $priority);
}
if(!$_conflict){
$this->_final_array[$_a["STARTTIME"]] = array(
"ENDDATE"       => $_a["ENDDATE"],
"STARTTIME"     => $_a["STARTTIME"],
"ENDTIME"       => $_a["ENDTIME"],
"PRESENTATION"  => $_a["PRESENTATION"],
"TITLE"         => $_a["TITLE"],
"PRIORITY"      => $_a["PRIORITY"],
);
}
}
}
$this->array_create_bookings(($priority+1), true);
}
}
}

final function array_to_parse($arr){
$this->_this_array = array();
foreach($arr as $key => $arrs){
$this->_final_array = array();
$this->_array = $arrs;
$this->array_sort_final();
$this->array_create_bookings();

asort($this->_final_array);

$this->_this_array[$key] = $this->_final_array;
}

/* The end result */
echo "<pre style='margin: 0; display: inline-block; width: 40%; background-color: #d1d2d4; vertical-align:top; padding: 10px 20px 20px 20px; box-sizing: border-box;'>";
echo "<h2>Test</h2>";
print_r($this->_this_array);
echo "</pre>";
}
}

$array_test_class = new array_test_class();
$array_test_class->array_to_parse($json_decode); /* $json_decode contains the booked elements i need to sort each day */
0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]