$arr = ['test' => ['gg' => ['tt' => []], 'hh' => ['ii' => []]]];
function get(array $array, ...$params) {
$result = $array;
foreach ($params as $param) {
$result = $result[$param] ?? null;
}
return $result;
}
var_dump(get($arr, 'test', 'gg', 'tt'));
var_dump(get($arr, 'test', 'gg'));
var_dump(get($arr, 'test', 'hh'));
$users = DB::table('users')->whereIn('id', [1, 2, 3])->get();
array(
'title' => 'Name',
'link' => 'link',
'children' => array(
array(
'title' => 'Name',
'link' => 'link',
'children' => array()
),
array(
'title' => 'Name',
'link' => 'link',
'children' => array()
)
)
)
function addEvent(elem, type, handler){
if(elem.addEventListener){
elem.addEventListener(type, handler, false);
} else {
elem.attachEvent('on'+type, handler);
}
return false;
}
function scrollDirection(){
var weelEvt = (/Firefox/i.test(navigator.userAgent)) ? 'DOMMouseScroll' : 'mousewheel',
el = document.body;
addEvent(el, weelEvt, function(e){
var evt = e.originalEvent ? e.originalEvent : e,
delta = evt.detail ? evt.detail*(-40) : evt.wheelDelta;
e.preventDefault();
var anchor = $('li.active a');
if (delta < 0) {
// вниз
anchor = anchor.parent().next().find('a');
} else if (delta > 0) {
// вверх
anchor = anchor.parent().prev().find('a');
}
if ($(anchor.attr('href')).offset() != undefined) {
anchor.click();
}
});
}
$(function(){
scrollDirection();
});