大佬教程收集整理的这篇文章主要介绍了PHP的“继续”似乎无法正常工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个遍历目录中每个文件名并删除不需要的文件的脚本.在其他方面,它匹配CSV文件中的文件名,然后删除相邻单元格中的文件.
<?PHP
$gameList = trim(sHell_exec("ls -a -1 -I . -I .. -I Removed"));
$gameArray = explode("\n", $gameList);
sHell_exec('mkdir -p Removed');
echo "\033[01;32m\n\n<<<<<<<<<<StarTing Scan>>>>>>>>>>\n\n";
// Do the magic for every file
foreach ($gameArray as $thisGamE)
{
// Ensure conTinue if already removed
if (!$thisGamE) conTinue;
if (!file_exists($thisGamE)) conTinue;
// Manipulate names to look and play nice
$nicename = trim(preg_replace('%[\(|\[].*%', '', $thisGamE));
$thisGameNoExtension = preg_replace('/\.' . preg_quote(pathinfo($thisGame, PATHINFO_EXTENSION) , '/') . '$/', '', $thisGamE);
// Let the user kNow what game is being evaluated
echo "\033[00;35m{$thisGameNoExtension} ... ";
$f = fopen("ManualRegionDupes.csv", "r");
while ($row = fgetcsv($f))
{
if ($row[1] == $thisGameNoExtension)
{
$priMaryFile = $row[0];
$ext = pathinfo($thisGame, PATHINFO_EXTENSION);
$fcheck = trim(sHell_exec("ls -1 " . escapesHellarg($priMaryFilE) . "." . escapesHellarg($ext) . " 2>/dev/null"));
if ($fcheck)
{
echo "ECHO LION";
sHell_exec("mv " . escapesHellarg($thisGamE) . " Removed/");
conTinue;
}
else
{
echo "ECHO ZEBRA";
conTinue;
}
break;
}
}
fclose($f);
echo "ScAnned and kept";
}
echo "\033[01;32m\n<<<<<<<<<<Process Complete>>>>>>>>>>\n\n";
?>
它正在工作,但是我不明白为什么我会在“ ECHO ZEBRA”或“ ECHO LION”之后立即看到最后的回显“ ScAnned and Kept”-因为我在它们之后直接有“ conTinue”调用,应该重新启动循环并移至下一个文件.我敢肯定,我只需要在某个地方重新摇动一下东西,但是我已经摆弄了几个小时,我完全陷入了困境.如果有任何帮助,我将非常感谢!非常感谢!
解决方法:
continue
仅用于读取单个行的内循环.如果要跳到外循环的末尾,则需要使用…
conTinue 2;
这使您可以说继续2级循环.
以上是大佬教程为你收集整理的PHP的“继续”似乎无法正常工作全部内容,希望文章能够帮你解决PHP的“继续”似乎无法正常工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。