我有一个像这样的多维数组:
$sidebar_booking = array(
'booking' => array(
'levels' => array('1'),
'title' => 'Booking',
'icon' => 'fa-calendar',
'sub' => array(
'rates-availability' => array(
'levels' => array('1'),
'title' => 'Tariffe e Disponibilità',
'sub' => array(
'booking-overview' => array(
'levels' => array('1'),
'title' => 'Panoramica',
'url' => '/ctrl/booking/overview/',
),
'booking-setup' => array(
'levels' => array('1'),
'title' => 'Setup Camere / Tariffe',
'url' => '/ctrl/booking/setup/',
),
'booking-prices' => array(
'levels' => array('1'),
'title' => 'Modifica Prezzi',
'url' => '/ctrl/booking/prices/',
),
'booking-availability' => array(
'levels' => array('1'),
'title' => 'Modifica Disponibilità',
'url' => '/ctrl/booking/availability/',
),
'booking-openclose' => array(
'levels' => array('1'),
'title' => 'Apri / Chiudi Camere',
'url' => '/ctrl/booking/openclose/',
),
'booking-restrictions' => array(
'levels' => array('1'),
'title' => 'Restrizioni',
'url' => '/ctrl/booking/restrictions/',
),
'booking-rates' => array(
'levels' => array('1'),
'title' => 'Tariffe',
),
),
),
'booking-promo' => array(
'levels' => array('1'),
'title' => 'Promozioni',
'url' => '/ctrl/booking/promo/',
),
'booking-reservations' => array(
'levels' => array('1'),
'title' => 'Prenotazioni',
'url' => '/ctrl/booking/reservations/',
),
)
),
);
我用它来创建我的(嵌套)侧边栏菜单
现在,给定一个匹配上例中url
之一的字符串,我想使用title
s
即,给定字符串/ctrl/booking/prices/
我想获得以下列表(然后我可以使用CSS转换为breadcrumb):
(你看我在数组中向后移动,查找标题;请注意,最后一项与url
相关联)
我真的被困在上面,这超出了我的技能:-(
提前谢谢!
答案 0 :(得分:1)
您可以尝试这样
for(LatLng point : new LatLng[]{POINTA, POINTB, POINTC, POINTD}) {
target.setLatitude(point.latitude);
target.setLongitude(point.longitude);
if(location.distanceTo(target) < METERS_100) {
// bingo!
}
}
答案 1 :(得分:0)
编辑版
function getTitle(Array $arr, $find) {
foreach($arr as $val){
if (isset($val['url']) && $val['url'] == $find) {
return '<li><a href="' . $val['url'] . '">' . $val['title'] . '</a></li>';
}
if (isset($val['sub'])) {
return '<li>' . $val['title'] . '</li>' . getTitle( $val['sub'], $find);
}
}
return false;
};