Join Kevin Skoglund for an in-depth discussion in this video Convert from metric length, part of Easy PHP Projects: Measurement Conversion.
- View Offline
- We have learned how to convert any unit into meters.…Now, we're ready to learn how to perform the reverse…operation, converting meters into any length unit.…As an example, let's look at how we…go about converting meters into feet.…We've already seen that 1 foot is equal to 0.3048 meters.…And the formula that we use for converting 3 feet into…meters is to multiply that number of feet by our number,…0.3048, and that gives us the number of meters.…
In order to convert from meters to feet,…it's the reverse operation.…And that means division.…We take the number of meters that we have.…We divide it by 0.3048, and that…tells us how many feet we have.…It's that easy.…It's just division instead of multiplication.…Let's write a convert from meters function in PHP.…So the best way to write our convert from meters function…and save ourselves a lot of typing is to copy…this function that we already wrote for convert to meters,…and then just paste it down here.…
I'm actually going to scroll up to the top here.…TextMate gives me the ability to fold these up,…
Along the way, series designer Kevin Skoglund introduces coding strategies, refactoring techniques, and useful skills including dynamically generating form select-option values and formatting decimal numbers and scientific notation.
- Converting length and area measurements
- Using functions to avoid repetition
- Refactoring to produce simpler code
- Converting volume and mass
- Generating form select-option values dynamically
- Formatting scientific notation
- Converting speed and temperature