$groups = [];
foreach ($data as $item) {
$groups[$item['title']][] = $item;
}
echo implode('', array_map(function($group, $title) {
$items = implode('', array_map(function($item) {
$name = $item['name'];
return "<div>$name</div>";
}, $group));
return "<h4>$title:</h4>$items";
}, $groups, array_keys($groups)));
Не могу понять как правильно написать цикл перебора.
$('.hello').attr('data-class', function() {
return [...this.classList].filter(n => n !== 'hello');
});document.querySelectorAll('.hello').forEach(n => {
n.dataset.class = n.className.replace(/(^| )hello( | $)/, ' ').trim();
});$('.hello').attr('data-class', function() {
return this.classList[1];
});document.querySelectorAll('.hello').forEach(n => {
n.dataset.class = n.className.split(' ').pop();
});
Array.prototype.push.apply(
arr,
newArr.filter(n => !arr.some(m => m.trade_id === n.trade_id))
);const pushDiff = (target, source, key = n => n) =>
target.push(...source.filter(function(n) {
return !this.has(key(n));
}, new Set(target.map(key))));
pushDiff(arr, newArr, n => n.trade_id);
Пробовал через массивы, но не работает.
['negative', '', 'positive'][Math.sign(article.total_comments.length) + 1]
import Vue from 'vue/dist/vue.esm.js'import Vue from 'vue'
.row {
counter-reset: list -1;
}
.row a::before {
content: counter(list);
counter-increment: list;
}
.row a:first-child::before,
.row a:last-child::before {
content: "";
}.row {
counter-reset: list 0;
}
.row a:not(:first-child, :last-child)::before {
content: counter(list);
counter-increment: list;
}
const inputSelector = '#kmOutMKAD';
const radioSelector = '[name="delivery"]';
const disabledValue = '1';$(radioSelector).on('change', function() {
$(inputSelector).prop('disabled', this.value === disabledValue);
});
// или
const input = document.querySelector(inputSelector);
const radios = document.querySelectorAll(radioSelector);
const onChange = e => input.disabled = e.target.value === disabledValue;
radios.forEach(n => n.addEventListener('change', onChange));
$scope.edit = function(index) {
$scope.active = index;
};ng-disabled="$index !== active"