Возможно ли это сделать в javascript не копируя слова в переменную, а обращением к файлу
let xhr = new XMLHttpRequest();
xhr.open('GET', 'file.txt', false); // либо "file.json"
xhr.send();
let file = xhr.responseText || '';
// а дальше уже делаете с файлом, что хотите
// либо разбиваете на строки с помощью разделителя "перенос строки"
let strings = file.split(/[\r\n]+/);
// либо разбиваете на слова разделителем "перенос строки или пробел"
let words = file.split(/[\s\r\n]+/);
// это данные формы - const data = { titleName: title.value, descrName: descr.value, typeName: type.value, rngFieldName: rngField.value, };
xhr.send(JSON.stringify({
titleName: title.value,
descrName: descr.value,
typeName: type.value,
rngFieldName: rngField.value,
}));
$price = $data->ticker->price;
object(stdClass)#2 (4) {
["ticker"]=>
object(stdClass)#1 (5) {
["base"]=>
string(3) "BTC"
["target"]=>
string(3) "RUR"
["price"]=>
string(15) "475260.76937314"
["volume"]=>
string(13) "1206.63030836"
["change"]=>
string(10) "3.44370048"
}
["timestamp"]=>
int(1521061861)
["success"]=>
bool(true)
["error"]=>
string(0) ""
}
$items = $exited['response']['items'];
foreach ($items as $item) {
echo 'message id: ' . $item['id'] . '<br>' . PHP_EOL;
echo 'message text: ' . $item['body'] . '<br>' . PHP_EOL;
echo 'user id: ' . $item['user_id'] . '<br>' . PHP_EOL;
// и тд
}
$json_decode->date-add-wl->field->data->
и тд $arr = [
[
'ID' => '105653877',
'CABLAB_NAME' => 'Участок',
'DEPARTMENT_NAME' => 'Отдел',
'DEPARTMENT_KIND' => '6405222',
'EMPLOYER_ID' => '78621962',
'EMPLOYER_NAME' => 'Иванов И. И.',
'SERVICE_ID' => '',
'SERVICE_NAME' => '',
'DEVICE_NAME' => '',
'DAY_NUMBER' => '1',
'HOURS_BEGIN' => '08',
'MINS_BEGIN' => '00',
'HOURS_END' => '14',
'MINS_END' => '00',
'TIME_BEGIN_S' => '08:00',
'TIME_END_S' => '14:00',
'TIME_TYPE' => '6338504',
'TIME_TYPE_CODE' => '1',
'RCOUNT' => '1',
'RCOUNTMAX' => '',
'TIME_OR_COUNT' => '0',
'RTIME_PRIM' => '15',
'SORT_F' => '2',
'ONLY_VIEW' => '0',
],
[
'ID' => '105653877',
'CABLAB_NAME' => 'Участок',
'DEPARTMENT_NAME' => 'Отдел',
'DEPARTMENT_KIND' => '6405222',
'EMPLOYER_ID' => '78621962',
'EMPLOYER_NAME' => 'Иванов И. И.',
'SERVICE_ID' => '',
'SERVICE_NAME' => '',
'DEVICE_NAME' => '',
'DAY_NUMBER' => '3',
'HOURS_BEGIN' => '08',
'MINS_BEGIN' => '00',
'HOURS_END' => '14',
'MINS_END' => '00',
'TIME_BEGIN_S' => '08:00',
'TIME_END_S' => '14:00',
'TIME_TYPE' => '6338504',
'TIME_TYPE_CODE' => '1',
'RCOUNT' => '1',
'RCOUNTMAX' => '',
'TIME_OR_COUNT' => '0',
'RTIME_PRIM' => '15',
'SORT_F' => '2',
'ONLY_VIEW' => '0',
],
[
'ID' => '105653877',
'CABLAB_NAME' => 'Участок',
'DEPARTMENT_NAME' => 'Отдел',
'DEPARTMENT_KIND' => '6405222',
'EMPLOYER_ID' => '78621962',
'EMPLOYER_NAME' => 'Иванов И. И.',
'SERVICE_ID' => '',
'SERVICE_NAME' => '',
'DEVICE_NAME' => '',
'DAY_NUMBER' => '5',
'HOURS_BEGIN' => '08',
'MINS_BEGIN' => '00',
'HOURS_END' => '14',
'MINS_END' => '00',
'TIME_BEGIN_S' => '08:00',
'TIME_END_S' => '14:00',
'TIME_TYPE' => '6338504',
'TIME_TYPE_CODE' => '1',
'RCOUNT' => '1',
'RCOUNTMAX' => '',
'TIME_OR_COUNT' => '0',
'RTIME_PRIM' => '15',
'SORT_F' => '2',
'ONLY_VIEW' => '0',
]
];
$new_arr = [];
foreach ($arr as $index => $item) {
$id = $item['ID'];
$new_arr[$id] = $new_arr[$id] ?? $item;
$day = $item['DAY_NUMBER'];
$days = explode(', ', $new_arr[$id]['DAY_NUMBER']);
if (!in_array($day, $days))
$days[] = $day;
sort($days);
$new_arr[$id]['DAY_NUMBER'] = implode(', ', $days);
}