Сортировка массива , PHP
Доброго времени суток.
Имеется массив вида:
38 => [],
3800 => [],
32 => [],
3200 => [],
Необходимо его отсортировать так, чтобы "совпадения" стали дочерними элементами, то есть такого вида:
38 => [
3800 => [],
],
32 => [
3200 => [],
],
Как можно это реализовать?
Ответы (1 шт):
Автор решения: De.Minov
→ Ссылка
Конечно, использовать самописный вариант лучше.
Но данный слайдер (Swiper) советую к использованию, к тому же на нём можно реализовать много чего.
const swiper = new Swiper('.swiper', {
speed: 400,
spaceBetween: 20,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-pagination',
type: 'fraction',
},
autoplay: {
delay: 5000,
pauseOnMouseEnter: true,
},
scrollbar: {
el: '.swiper-scrollbar',
draggable: true,
dragSize: 20
},
});
@import url('https://unpkg.com/swiper@8/swiper-bundle.min.css');
.max-wrap {
max-width: 600px;
margin: 0 auto;
}
.swiper {
width: 100%;
padding-bottom: 7.5px;
}
.swiper-slide {
max-height: 400px;
background: #ccc;
position: relative;
}
.swiper-slide span {
display: block;
position: absolute;
left: 0;
top: 0;
}
.swiper-slide::before {
content: '';
display: block;
width: 100%;
padding-top: 50%;
}
.swiper-control {
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
}
.swiper-control > *:not(:last-child) {
margin-right: 20px;
flex-shrink: 0;
}
.swiper-button-next, .swiper-button-prev {
position: static;
width: 20px;
height: 20px;
margin-top: 0;
}
.swiper-button-next::after, .swiper-button-prev::after {
font-size: 20px;
}
.swiper-scrollbar-wrapper {
flex: 1 0 auto;
display: flex;
justify-content: flex-start;
align-items: center;
}
.swiper-scrollbar.swiper-scrollbar-horizontal {
width: 100%;
position: relative;
bottom: auto;
left: auto;
}
.swiper-scrollbar-drag {
width: 20px;
height: 20px;
border-radius: 50%;
margin-top: -7.5px;
}
.swiper-pagination {
width: auto;
position: static;
}
<script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
<div class="max-wrap">
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide"><span>Slide 1</span></div>
<div class="swiper-slide"><span>Slide 2</span></div>
<div class="swiper-slide"><span>Slide 3</span></div>
</div>
</div>
<div class="swiper-control">
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<div class="swiper-scrollbar-wrapper">
<div class="swiper-scrollbar"></div>
</div>
<div class="swiper-pagination"></div>
</div>
</div>