Tag Archives: logic

(HTML) Form element arrays

Sometimes you might want to group form elements in arrays. Here’s a way to do that: The structure of the \$_POST array will then be:

Convert seconds to days, hours, minutes and seconds

Converting seconds into days, hours, minutes and seconds int days = secondsTotal / 60 / 60 / 24; int hours = (secondsTotal / 60 / 60) % 24; int minutes = (secondsTotal / 60) % 60; int seconds = secondsTotal % 60;

Simple function to see if a number is Even or Odd.

Sometimes you need to check if a number is even or odd. A simple way to do this is using the modulus operator (the %-sign). It will calculate and return the remainder when dividing a value with another value. So how do you use that to find out if a number is even or odd?… Read More »

A couple of principles when learning how to code.

Principle 1. Always have a clear image of what you want to do BEFORE you start writing your code. Then break it down in logical instructions – making an algorithm.  An algorithm is a step by step instruction on how to solve a specific problem. You might think of it as a recipe. If you… Read More »