If ... else is issued: removing the consistent variable

I am new to coding and cannot set the idea for easy logic ... OK, I wrote the code, first, let's see:

<?php function month_ana($mna){ $c_mna = strlen($mna); echo "Let 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]); } } ?> 

what I want to do is delete the consistent variable, so the function will skip it.
See its output:

 Let Analysis January Total Charectars: 7 Let Analysis February Total Charectars: 8 Let Analysis March Total Charectars: 5 Let Analysis April Total Charectars: 5 Let Analysis May Total Charectars: 3 Let Analysis June Total Charectars: 4 Let Analysis July Total Charectars: 4 Let Analysis August Total Charectars: 6 Let Analysis September Total Charectars: 9 

but the problem is that I used the break(); operator break(); so it stops working when the variables are matched in October , but I want it to skip the matching variable without stopping here, so in that case it should skip October and then start computing again with November and continue. I hope you understand the problem. Any ideas?

If you think you should send me some articles, please do so because I really want to learn PHP programming. Thanks

+4
source share
3 answers

try continue;

 var $go = array('January', 'February', 'March', ...); foreach ($go as $month) { if ($month == $fo){ continue; } echo $month . '<br />'; } 
+2
source

use the continue keyword instead of break

+1
source
 for($i=0;$i<=11;$i++) { if ($go[$i] != $fo) { month_ana($go[$i]); } } 

I put '! = 'instead of' == '.

If you use continue , it will start the loop again, but you said you want to continue from November after analyzing October.

0
source

All Articles