N
N
ngapp2019-10-07 18:53:25
PHP
ngapp, 2019-10-07 18:53:25

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
5d9b5ec2eb95a037275430.png
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 [ ] ... ] ];

Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-10-08
@hypnogaja

$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>';

5d9ba8b3a76b1759782540.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question