<?php
$taskArray = array('1', '2', '3', '4', '5');
$deviceArray = array('Coolpad8705', 'HM2014011');
foreach($taskArray AS $t) {
$task = $model->get($t);
$a = false;
foreach($deviceArray AS $device) {
if ($model->is($device) == false) {
$a = true;
break;
}
}
if ($a === false) continue;
}Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
foreach($taskArray AS $t) { $task = $model->get($t); // $a = false; // foreach($deviceArray AS $device) { // if ($model->is($device) == false) { // $a = true; // break; // } // } // if ($a === false) continue; if ( ! in_array($model->device(), $deviceArray)) // do something }$model->is 是什么作用?
get($t);//What's this ? $a = false; foreach($deviceArray AS $device) { if ($model->is($device) == false) { //false == $model->is($device) $a = true; continue; //break } } if ($a === false) continue; //delete this }两句continue;是没用的。
请区分continue;和break;的效果。
不写这两句没有任何影响,换成break;可以减少循环次数。
优雅什么的……
简洁、有效、有注释就好。
IDE会自动处理好格式的。