条件陈述的问题 [英] Question on conditional statements

查看:69
本文介绍了条件陈述的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是一名perl程序员,正在努力学习PHP。


到目前为止,我已经找到了大部分内容差异,但一直无法确定如何执行以下操作:


当循环运行时,如何测试两个不同的条件

对阵阵列的相同$元素。例如,这就是我认为它将如何完成(类似于Perl),但它不起作用:


if(eregi(") apple",$ line)和(eregi(" orange",$ line){


做任何事;


}


基本上测试一个数组的每一行,看看是否存在单词apple和

" orange。


此外,在通过循环运行

时,是否有与Perl相同的内容:


next if(无论条件);

最后如果(无论条件);


谢谢,

Max

解决方案

一个数组的元素。例如,这就是我认为它将如何完成(类似于Perl),但它不起作用:


if(eregi(" apple",


line)和(eregi(" orange",


line) {


做什么永远;


}


基本上测试一个数组的每一行,看看两个单词是否都是apple。和

" orange"是的。


此外,在通过循环运行

时,是否有与Perl相同的内容:


$ next(无论条件);

最后如果(无论条件);


谢谢,

Max

Hi,

I''m a perl programmer and am trying to learn PHP.

So far I have figured out most of the differences, but have not been able to
find out how to do the following:

When running through a loop, how can you test two separate conditions
against the same $element of an array. For example, this is how I thought it
would be done (similar to Perl), but it did not work:

if (eregi("apple", $line) and (eregi("orange", $line) {

do whatever;

}

Basically testing each line of an array to see if both the words "apple" and
"orange" are present.

Also, is there any equivalent to the following from Perl while running
through a loop:

next if (whatever conditions);
last if (whatever conditions);

Thanks,
Max

解决方案

element of an array. For example, this is how I thought it
would be done (similar to Perl), but it did not work:

if (eregi("apple",


line) and (eregi("orange",


line) {

do whatever;

}

Basically testing each line of an array to see if both the words "apple" and
"orange" are present.

Also, is there any equivalent to the following from Perl while running
through a loop:

next if (whatever conditions);
last if (whatever conditions);

Thanks,
Max


这篇关于条件陈述的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆