[Solved] PHP if statement with OR operators [closed]

Use || statement. <?php if($CURRENT_USER[‘selected_plan_id’] == ‘4’ || $CURRENT_USER[‘selected_plan_id’] == ‘5’ || $CURRENT_USER[‘selected_plan_id’] == ‘6’): ?> Or Use in_array(). $arr = Array (4,5,6); <?php if(in_array($CURRENT_USER[‘selected_plan_id’],$arr)): ?> 1 solved PHP if statement with OR operators [closed]

[Solved] php if elseif statement select wrong variable every time [closed]

You have to write if($_POST[‘postnummer’] == “7900” || $_POST[‘postnummer’] == “7950” || $_POST[‘postnummer’] == “7960”) { $region = “Nordjylland”; } elseif ($_POST[‘postnummer’] == “8654” || $_POST[‘postnummer’] == “8660” || $_POST[‘postnummer’] == “8680” || $_POST[‘postnummer’] == “8700”) { $region = “Midtjylland”; } solved php if elseif statement select wrong variable every time [closed]

[Solved] Cleaner way to write code snippet

if you’re only comparing a few values then you might as well proceed with the current approach as there is nothing in place to make it shorter. However, if you’re repeating your self many times, then you can create a helper function to do the work for you. i.e static boolean anyMatch(int comparisonValue, int… elements){ … Read more

[Solved] No curly braces if else statements?

It will print out 5. It doesn’t even approach to the second if-else, because doesn’t pass the first condition x!=5 and the else statement is missing and it goes to the last line where you print the variable out. It’s the same as: int x=5, y=5, z=5; if (x!=5) { if (y<=7) { z=z+4; } … Read more