{
"filmName":{
"2014-08-20":
["10:20","16:15","18:25"],
"2014-08-15":
["10:20","16:15","18:25"]
}
}
Array ( [Неудержимые 3] => array( 2014-08-19 => array(10:20, 16:15, 18:25, 20:40, 23:00),
2014-08-19 => array(10:20, 16:15, 18:25, 20:40, 23:00) ) )
$myArray = array(...);
$remakeArray = function($myArray){
$convertArray = array();
for($key in $myArray){
if($convertArray[$myArray[$key]["films_title_rus"]]){
$convertArray[$myArray[$key]["films_title_rus"]] = array();
}
$convertArray[$myArray[$key]["films_title_rus"]][$myArray[$key]["schedule_date"]] = $myArray[$key]["schedule_time"];
}
return $convertArray;
};
$myArray = $remakeArray($myArray);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4){
document.getElementById('response').innerHTML = xhr.responseText;
var responseArray = JSON.parse(xhr.responseText);
}
};
xhr.open("POST", "php/myRequest.php");
xhr.send();
<?php
header("Content-type: text/txt; charset=UTF-8");
$link = mysqli_connect('localhost', 'root', '', 'myDB');
if (!$link) {
echo('Ошибка соединения');
}
$result = mysqli_query($link, 'select * from myTable');
$resultArray = array();
while ($line = mysqli_fetch_array($result, MYSQLI_NUM)) {
$resultArray[] = $line;
}
$result->close();
$res = json_encode($resultArray, JSON_UNESCAPED_UNICODE);
echo $res;
$link->close();
?>