dqkkrt8860 2013-08-30 10:52
浏览 6
已采纳

从php中的数组获取值并爆炸

I have this the values of in my array as

$itsthere = (item1-0-100, item2-0-50, item3-0-70, item4-0-50, item5-0-100);

If the user enter the value item3 he has to get 70 which is present in array. I tried alot using explode but its not showing proper value. Can any one help me.

  • 写回答

3条回答 默认 最新

  • douyong8801 2013-08-30 11:01
    关注

    Try this :

        $item = 'item3';
        $itsthere = array('item1-0-100', 'item2-0-50', 'item3-0-70', 'item4-0-50', 'item5-0-100');
    
        foreach($itsthere as $there)
        {
            $exp = explode('-',$there);
            if($exp[0] == 'item3') {
                echo $val = $exp[2];
            };
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决
  • ¥15 java幂等控制问题
  • ¥15 海湾GST-DJ-N500
  • ¥15 氧化掩蔽层与注入条件关系
  • ¥15 Django DRF 如何反序列化得到Python对象类型数据
  • ¥15 多数据源与Hystrix的冲突
  • ¥15 如何在线硕士了解,广告太多,希望有真实接触过的人回答下?(标签-学习|关键词-在线硕士)
  • ¥15 zabbix6.4与frp如何进行联动