Round up to nearest 5

Posted on 2009-02-09
Last Modified: 2012-05-06
Hi there,

Wondered if there was a PHP that will round up a value to the nearest 5; it always has to round up and not down e.g 381 would be 385.
Question by:wellso
    LVL 10

    Accepted Solution

    Try the following:
    $var = 7;
    echo ceil($var / 5) * 5;

    Open in new window

    LVL 2

    Author Closing Comment

    Thanks bud, its all so simple now :-)
    LVL 40

    Expert Comment

    And today, I didn't have to work this out for myself.

    Thanks pvginkel.

    And to wellso for the question.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now