所有人!
我的网站上有一个通过PHP动态生成的办公室联系人列表(下面的部分代码段)。如您所见,每个列表结果/子级都有一个名称,地址,以及下一个div上的Google Maps框架。我想要实现的是调用数组的最新结果,并使其不显示google maps div。
[我想我可以用“ end()”命令来称呼它,但是我无法以正确的方式继续前进……有人可以指出我的正确方向吗?] >
谢谢!
<header id="standardheader">
<div class="wrap">
<nav class="standardsubnav">
<ul class="standardsubnav_list vanilla"><!--
<?php include_partial( 'contact/citynav', array('class' => 'standardsubnav') ); ?>
--></ul>
</nav>
<h1 class="standardpage_title"><?php echo $current->getHeadline(); ?></h1>
</div>
</header>
<div class="wrap">
<section class="">
<ul class="list4 vanilla">
<?php $contacts = $current->getChildren(); ?>
<?php foreach($contacts as $contact): $settings = $contact->getSettings(); ?>
<li class="item4">
<a name="<?php echo $settings['city']; ?>"></a>
<div class="link4">
<div class="link4_inner">
<h2 class="title4"><?php echo $settings['city']; ?></h2><!--
--><address class="address4">
<?php echo $settings['name']; ?><br />
<?php if(isset($settings['address1']) && $settings['address1'] != "") echo $settings['address1'] . '<br />'; ?>
<?php if(isset($settings['address2']) && $settings['address2'] != "") echo $settings['address2'] . '<br />'; ?>
<?php if(isset($settings['address3']) && $settings['address3'] != "") echo $settings['address3'] . '<br />'; ?>
<?php if(isset($settings['address4']) && $settings['address4'] != "") echo $settings['address4'] . '<br />'; ?>
<?php if(isset($settings['phone']) && $settings['phone'] != ""): ?><a href="tel:<?php echo str_replace(' ', '', $settings['phone']); ?>">t. <?php echo $settings['phone']; ?></a><br /><?php endif; ?>
<?php if(isset($settings['fax']) && $settings['fax'] != ""): ?><a href="tel:<?php echo str_replace(' ', '', $settings['fax']); ?>">f. <?php echo $settings['fax']; ?></a><br /><?php endif; ?>
<?php if(isset($settings['email']) && $settings['email'] != ""): ?><a href="mailto:<?php echo $settings['email']; ?>">e. <?php echo $settings['email']; ?></a><?php endif; ?>
</address>
</div><!--
--><div class="link4_inner">
<?php
$mapurl = (!empty($settings['mapurl'])) ? $settings['mapurl'] : 'https://www.google.com/maps/@' . $settings['latitude'] . ',' . $settings['longitude'] . ',' . $settings['zoom'] . 'z'; ?>
<div class="gmap4" data-gmap="<?php echo htmlspecialchars( '{"lat":"'.$settings['latitude'].'","lng":"'.$settings['longitude'].'", "zoom":"'.$settings['zoom'].'", "mapurl":"'.$mapurl.'"}' ); ?>">
<noscript><?php echo __('Please enable javascript to see the map.'); ?></noscript>
<?php end($contacts)
每个人!我的网站上有一个通过PHP动态生成的办公室联系人列表(下面的部分代码段)。如您所见,每个列表结果/子项都有一个名称,地址,并在随后的div上有一个...
计算$ contacts数组。然后在foreach循环中检查循环中当前元素beeing是否等于数组中的项目,如果等于项目,则为最后一个元素,然后退出foreach: