Class Item {
public string $name = '';
public float $qual = 0;
public function __construct(array $attributes = [])
{
foreach ($attributes as $key => $value) {
$this->$key = $value;
}
}
public function __toString()
{
return "$this->qual"; // семантическая х-ня
}
}
// ...
$items = array_map(function (array $item) {
return new Item($item);
}, $items);
var_dump("$items[0]" + 100);
class Items {
public array $items = [];
public function __construct(array $items = [])
{
$this->items = $items;
}
public function __invoke(int $key)
{
return $this->items[$key]['qual'] ?? null;
}
}
// ...
$items = new Items($items);
var_dump($items(0));
for (let i = 0; i <= 1;i++) { // вы перебираете первые две записи
if (new Date(response.data[i][1]).getDay() === 1) {
this.Monday = response.data; // и перезаписываете в нужный день ВСЮ выборку
}
}
this.daysData = new Array(7);
response.data.forEach(data => {
this.daysData[(new Date(data[1])).getDay()].push(data);
});
<div class="cityInfo" data-city="1">
<span class="cityInfo__city" data-city="1">1</span>
<span class="cityInfo__city" data-city="2">2</span>
</div>
<button class="cityToggler" data-city="1">toggle 1</button>
<button class="cityToggler" data-city="2">toggle 2</button>
.cityInfo .cityInfo__city { display: none; }
.cityInfo[data-city="1"] .cityInfo__city[data-city="1"] { display: block; }
.cityInfo[data-city="2"] .cityInfo__city[data-city="2"] { display: block; }
document.addEventListener('click', function (e) {
if (e.target.closest('.cityToggler')) {
document.querySelectorAll('.cityInfo').forEach(cityInfo => {
cityInfo.dataset.city = e.target.closest('.cityToggler').dataset.city;
});
}
});