Home > Backend Development > PHP Tutorial > php 双层循环控制,该如何处理

php 双层循环控制,该如何处理

WBOY
Release: 2016-06-13 13:39:36
Original
813 people have browsed it

php 双层循环控制
有两个循环,一个是(循环1)1,2,3....N,另一个是(循环2)a,b,c....z;
现在需要做判断,对循环1的每项内容判断是否在循环2里面,(如果在,找出来)我自己的代码如下:
for($i=1;$i++;iif(($i=a)||($i=b)||($i=c)($i=d).....)
echo '找到'$i;
}
感觉效率低下,欢迎指教。十分感谢。

------解决方案--------------------
commonjam(commonjam)
'截至2012-03-31 11:25:26 用户结帖率0.00%

当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html

8、如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖

------解决方案--------------------
前面各位大侠都说了,还没搞定嘛!
参考下面的,希望对你有帮助,多看看手册啊。。

PHP code

$arr1 = array('f','1','2','3','c');
$arr2 = array('a','b','c','d','e','f','g');
foreach($arr1 as $val){
    if(in_array($val, $arr2)){
        echo '找到'.$val.'<br>';
    }else{
        echo '没找到'.$val.'<br>';
    }
} <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template