dskzap8756 2015-11-23 14:14
浏览 40
已采纳

运行if / else语句并迷路

I'm having a brain dead moment and getting lost in my logic, please can someone help!

I'm looking to recreate 3 scenarios:

  1. If downloads AND resources exist.
  2. If only downloads exist.
  3. If only resources exist.

These are decided by the two statements:

Downloads = have_rows('downloads')

Resources = get_sub_field('resources')

How can I run through the 3 scenarios in an if/else loop?

  • 写回答

3条回答 默认 最新

  • doujiao2014 2015-11-23 14:18
    关注
    $downloads = have_rows('downloads');
    $resources = get_sub_field('resources');
    
    if($downloads && $resources) {
      // do something
    } elseif($downloads) {
      // do something else
    } elseif($resources) {
     // yet another something else
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题