我是编码新手,无法为简单的逻辑建立想法。
好吧,我已经写了一个代码,首先看看:
<?php
function month_ana($mna){
$c_mna = strlen($mna);
echo "Let's Analysis <b>$mna</b> <br> Total Charectars: $c_mna <br>";
}
$go[0] = "January";
$go[1] = "February";
$go[2] = "March";
$go[3] = "April";
$go[4] = "May";
$go[5] = "June";
$go[6] = "July";
$go[7] = "August";
$go[8] = "September";
$go[9] = "October";
$go[10] = "November";
$go[11] = "December";
$fo = "October";
$i = 0;
for($i=0;$i<=11;$i++){
if ($go[$i]==$fo){
break;
} else {
month_ana($go[$i]);
}
}
?>
我想做的是删除匹配的变量,所以函数会跳过它。
让我们看看它的输出:
Let's Analysis January
Total Charectars: 7
Let's Analysis February
Total Charectars: 8
Let's Analysis March
Total Charectars: 5
Let's Analysis April
Total Charectars: 5
Let's Analysis May
Total Charectars: 3
Let's Analysis June
Total Charectars: 4
Let's Analysis July
Total Charectars: 4
Let's Analysis August
Total Charectars: 6
Let's Analysis September
Total Charectars: 9
但问题是我使用break();
了语句,所以当变量匹配时它停止工作October
,但我希望这样,这将跳过匹配的变量而不是在这里停止,所以在这种情况下它应该跳过October
然后重新开始计算November
并继续。我希望你明白这个问题。有任何想法吗?
如果您认为应该向我推荐一些文章,那么请这样做,因为我非常热衷于学习 PHP 编程。谢谢