Answer the question
In order to leave comments, you need to log in
What is the best way to structure and display data in php?
Hello everyone, thanks to everyone who helped solve the previous issue with variables and time,
now the task is expanding and the flight of thoughts is not limited.
There is an XLS file with the following structure
Migration from XLS to CSV is clear, even with table transposition for "row" convenience.
How to organize the output of statistical data on the chart by places and days of the week ?
What storage structure for variables can be optimal?
$array [ $arrminsk2[ $arrMon[ ], $arrTue[ ], $arrWed [ ] ... ], $arrminsk3[ $arrMon[ ], $arrTue[ ], $arrWed [ ] ... ], $arrminsk4[ $arrMon[ ], $arrTue[ ], $arrWed [ ] ... ] ];
Answer the question
In order to leave comments, you need to log in
$file = 'file.csv';
$line = file($file);
$arr = [];
foreach ($line as $k => $v) {
$arr[] = explode(';', trim($v));
}
$days = ['пн', 'вт', 'ср', 'чт', 'пт', 'сб', 'вс'];
$result = [];
foreach ($arr as $k => $value) {
if ($k > 1) {
$result[array_shift($value)] = array_combine($days, array_chunk($value, 24));
}
}
echo '<pre>' . print_r($result, true) . '</pre>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question