Join David Powers for an in-depth discussion in this video Round numbers to a specific multiple, part of PHP Tips, Tricks, and Techniques.
- [David] Hi, I'm David Powers…and welcome to this week's edition of PHP Tips and Tricks…designed to help you become a smarter,…more productive PHP developer.…In this edition, I want to look at rounding numbers.…Not just to the closest integer, but to a specific multiple.…This can be useful when resizing images for a website.…The originals may be different sizes…and it's often important to resize them to a specific size…rather than to sum arbitrary figures…to preserve the unity of the page layout.…
Let's start with the basics.…You're probably familiar…with these three built in PHP functions.…By the way, you can follow along…with the exercise files provided with this video.…Round rounds up or down to the closest integer.…Floor always rounds down.…And ceil always rounds up.…So passing this number 98.6…to each of these functions produces these results.…We round up to 99.…Floor rounds down to 98.…And ceil rounds up to 99.…
Now let's switch to this other file.…A slightly more complicated example.…I was working with an image that was this height…
Note: The exercise files are free to all members. The code is commented to enhance your learning, but you will need database connectivity for some files to run as intended.
Skill Level Intermediate
PHP: Managing Persistent Sessionswith David Powers2h 41m Intermediate
New this Week:
Creating a download link New9m 45s
1. Weekly Episodes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.