加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Array Loop – 将第一个值放入foreach循环中

发布时间:2020-12-13 17:02:37 所属栏目:PHP教程 来源:网络整理
导读:我有一个数组,我希望将第一个值放入foreach循环中.然后将该值发送给函数. 这不起作用 foreach ($frequency as $i) { showphp_AlexVortaro (getphp_AlexVortaro ($frequency[$i])); showphp_Smartfm(getphp_Smartfm($frequency[$i])); } 解决方法 我认为你的
我有一个数组,我希望将第一个值放入foreach循环中.然后将该值发送给函数.

>这不起作用

foreach ($frequency as $i) {        
   showphp_AlexVortaro (getphp_AlexVortaro ($frequency[$i]));
   showphp_Smartfm(getphp_Smartfm($frequency[$i]));        
}

解决方法

我认为你的意思是使用当前的’公开’偏移量作为函数的参数:

foreach($frequency as $i) {        
   showphp_AlexVortaro (getphp_AlexVortaro($i));
   showphp_Smartfm(getphp_Smartfm($i));        
}

要么:

for($i=0; $i<count($frequencies); $i++) {        
   showphp_AlexVortaro(getphp_AlexVortaro($frequencies[$i]));
   showphp_Smartfm($frequencies[$i]);        
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读