$sourceArr = array
(
"1" => array
(
"0" => 123,
"1" => 412412,
"2" => 21424124,
"3" => array
(
"0" => 12,
"1" => 24
)
),
"2" => array
(
"4" => 444,
"5" => 5555
)
);
$destArr = array
(
"32" => array
(
"7" => 4124124,
"8" => 124124,
"9" => 124124,
"5" => array
(
"7" => 76,
"6" => 98
)
),
"34" => array
(
"10" => 99999,
"11" => 888888
)
);
function exchangeItem($sourceArray, &$destinationArray)
{
$srcArrKeys = array_keys($sourceArray);
$destArrKeys = array_keys($destinationArray);
$counter = 0;
foreach($destinationArray as &$currentItem)
{
if(is_array($currentItem))
{
$currentItem = exchangeItem($sourceArray[$srcArrKeys[$counter]], $currentItem);
}
else
{
$currentItem = $sourceArray[$srcArrKeys[$counter]];
}
$counter++;
}
return $destinationArray;
}
$destArr = exchangeItem($sourceArr, $destArr);
print_r($destArr);
зашёл на ту страницу откуда вы мне дали ссылку
event.item.index++
(event.item.index++) == event.item.count
owl.on('changed.owl.carousel', function(event)
{
console.log('Всего: ' + event.item.count + ' Текущий: ' + event.item.index)
})
$sourceArr = array
(
"1" => array
(
"0" => 123,
"1" => 412412,
"2" => 21424124,
)
);
$destArr = array
(
"32" => array
(
"7" => 4124124,
"8" => 124124,
"9" => 124124,
)
);
$sourseArrOutterKeys = array_keys($sourceArr);
$outterCounter = 0;
foreach($destArr as $destOutterKey => $destOutterValue)
{
$sourseArrInnerKeys = array_keys($sourceArr[$sourseArrOutterKeys[$outterCounter]]);
$innerCounter = 0;
foreach($destOutterValue as $destInnerKey => $destInnerValue)
{
$destArr[$destOutterKey][$destInnerKey] =
$sourceArr[$sourseArrOutterKeys[$outterCounter]][$sourseArrInnerKeys[$innerCounter]];
$innerCounter++;
}
$outterCounter++;
}
print_r($destArr);
function callback(event) {
// Provided by the core
var element = event.target; // DOM element, in this example .owl-carousel
var name = event.type; // Name of the event, in this example dragged
var namespace = event.namespace; // Namespace of the event, in this example owl.carousel
var items = event.item.count; // Number of items
var item = event.item.index; // Position of the current item
// Provided by the navigation plugin
var pages = event.page.count; // Number of pages
var page = event.page.index; // Position of the current page
var size = event.page.size; // Number of items per page
}
пишу такую строчку, в консоли пишет нет "event"
может ещё подскажете как узнать кол-во слайдов в карусели и какой текущий слайд?
owl = $('#owl-carousel');
owl.owlCarousel
({
items: 5,
nav: true,
// Остальные настройки .....
onInitialized: carouselInitialized
});
...
function carouselInitialized(event)
{
$('.owl-prev').addClass('classNameToPrevButton');
$('.owl-next').addClass('classNameToNextButton');
}
var b = document.querySelector('body');
var arr = [1,4,2,43,54,30,6,3];
for (var i = 0; i < arr.length; i++) {
var el = document.createElement('div');
var tag = arr[i];
el.appendChild(document.createTextNode('chto-to #'+tag));
b.appendChild(el);
el.addEventListener('click', function(e) {
someFunc(e);
});
}
function someFunc(v) {
console.log(v.target.innerHTML.split(' ')[1]);
}