简体   繁体   English

php 列表 - 将项目放在单独的行上

[英]php list - to put items on separate lines

I am not confident enough with this code to figure out how to change it so I hope someone can help me.我对这段代码没有足够的信心来弄清楚如何改变它,所以我希望有人能帮助我。 Its from a php doc for my google map directory.它来自我的 google map 目录的 php 文档。 I purchased the plugin and have spent days configuring the style.css to be how I want it to be but this part is in a php file so Im not confident playing around with it.我购买了该插件,并花了几天时间将 style.css 配置为我想要的样子,但这部分在 php 文件中,所以我没有信心玩弄它。 In the map settings there are two fields, one for phone number and one for location.在 map 设置中有两个字段,一个用于电话号码,一个用于位置。 When the directory is showing on live page, it lists these two next to each other like "123 private street ph 09 1234564".当目录显示在实时页面上时,它将这两个彼此相邻列出,例如“123 private street ph 09 1234564”。 I need them to each display on a separate line so phone number is under address.我需要它们在单独的线路上显示,所以电话号码在地址下。 Can someone please help me with this code so it will do that.有人可以帮我处理这段代码,这样它就可以了。 The code is:代码是:

<p>
  <?php echo trim($list['qcpd_item_subtitle']); ?>
  <?php if(isset($list['qcpd_item_phone'])&&$list['qcpd_item_phone']!='') {
    echo '<span style="display:block;font-size:11px">';

    if(isset($list['qcpd_item_location']) and $list['qcpd_item_location']!=''){
      echo ' <span style="font-weight:bold">'.$list['qcpd_item_location'].'</span> &nbsp;&nbsp;';
    }
    echo ($phone_number=='1'?'<span class="sbd_phone"><i class="fa fa-phone"></i> '.str_replace(array('(',')'),array('',''),$list['qcpd_item_phone']).'</span>':'');

    echo '</span>';

  }?>  
</p>
</div>

many thanks Julie非常感谢朱莉

You can add <br /> (line break) after <span> with location, or change the <span> tags to <div> .您可以在<span>之后添加<br /> (换行符)和位置,或者将<span>标签更改为<div>

With <br /><br />

<p>
  <?php echo trim($list['qcpd_item_subtitle']); ?>
  <?php if(isset($list['qcpd_item_phone'])&&$list['qcpd_item_phone']!='') {
    echo '<span style="display:block;font-size:11px">';

    if(isset($list['qcpd_item_location']) and $list['qcpd_item_location']!=''){
      echo ' <span style="font-weight:bold">'.$list['qcpd_item_location'].'</span><br />';
    }
    echo ($phone_number=='1'?'<span class="sbd_phone"><i class="fa fa-phone"></i> '.str_replace(array('(',')'),array('',''),$list['qcpd_item_phone']).'</span>':'');

    echo '</span>';

  }?>  
</p>

With <div></div><div></div>

<p>
  <?php echo trim($list['qcpd_item_subtitle']); ?>
  <?php if(isset($list['qcpd_item_phone'])&&$list['qcpd_item_phone']!='') {
    echo '<div style="display:block;font-size:11px">';

    if(isset($list['qcpd_item_location']) and $list['qcpd_item_location']!=''){
      echo ' <div style="font-weight:bold">'.$list['qcpd_item_location'].'</div> &nbsp;&nbsp;';
    }
    echo ($phone_number=='1'?'<div class="sbd_phone"><i class="fa fa-phone"></i> '.str_replace(array('(',')'),array('',''),$list['qcpd_item_phone']).'</div>':'');

    echo '</div>';

  }?>  
</p>

There should not be any difference between both approaches, however, because <div></div> is automatically followed by line-break it might break your tooltip/item style.但是,这两种方法之间应该没有任何区别,因为<div></div>后面会自动出现换行符,它可能会破坏您的工具提示/项目样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM