-1

地狱所有,

我正在努力使我的代码更清洁,你们能否让我知道以下内容是否真的有效。从我的测试来看,我似乎无法分辨,因为它会随着比赛而持续。请帮助并提前感谢您。

$minar=array('1','2','9','0');
if ($phpmins>"2" && in_array(substr($phpmins, -1),$minar) && $phpmins<$newmax)

我担心的部分是:&& in_array(substr($phpmins, -1),$minar)

您可以将 substr 嵌套在 in_array 中吗?

4

1 回答 1

0

Yes you can. substr returns a value which is then passed to in_array as the first parameter. These are all equivalent in this respect:

in_array('foo', $minar)
in_array($var, $minar)
in_array(someFunction(), $minar)

Those are the basic rules of programming and values/variables/function return values.

于 2012-04-25T05:27:57.547 回答