Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:50:22+00:00 2026-06-04T11:50:22+00:00

Simple question, how do I get every option when dividing a number? For example:

  • 0

Simple question, how do I get every option when dividing a number? For example:

  • 24 by 6 returns 6, 12, 18, 24
  • 24 by 4 returns 4, 8, 12, 16, 20, 24
  • 24 by 5 returns false

I’ve got a number in my database, for example 2, and my counter, for example 14. That means every time my counter hits the second number, I want to fire my event. So I thought, if I have the solutions 2, 4, 6, etc, and my counter is equal to one of the solutions, I can fire my event.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:50:24+00:00Added an answer on June 4, 2026 at 11:50 am

    It’s rather trivial to make.

    <?php
    
    /**
     * @param int $number  The beginning number
     * @param int $divider The number dividing by
     *
     * @return array
     * @throws Exception   In case $number is not divisible by $divider
     */
    function get_number_sequence($number, $divider) {
        //In case $number is not divisible by $divider, throw an Exception.
        if ($number % $divider !== 0) {
            throw new Exception("$number is not divisible by $divider");
        }
        //Return an array from $divider to $number in steps of $divider.
        $result = range($divider, $number, $divider);
        return $result;
    }
    
    /*
     * Testing begins
     */
    
    try {
        echo "<pre>";
        echo implode(", ", get_number_sequence(24, 4)) . PHP_EOL;
        echo implode(", ", get_number_sequence(24, 6)) . PHP_EOL;
        echo implode(", ", get_number_sequence(24, 5)) . PHP_EOL;
        echo "</pre>";
    }
    catch (Exception $e) {
        echo "Invalid: " . $e->getMessage();
    }
    

    Some Points

    • Don’t return false if something exceptional happens, use an Exception as shown in the example.
    • Use the modulus operator to determine if the number is divisible or not.
    • Return an array, not a string. It’s easier to work with.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a simple question in the objectify documentation it says that Only get(),
Question is simple, I want to map every number from 0 to N-1 to
Simple question, I should think. Unfortunately, I couldn't figure out how to get it
Probably a simple question: Why do I get an compiler warning for the following
This is a simple question: Is this a correct way to get an integer
This should be a simple question, but I can't get it to work :(
This is a really simple question. Is it possible for jQuery to get an
I have what I think is a simple question but I can't get it
my question is simple.... How to get rid of the white background color of
i'm implementing an eventreceiver, my question is simple : how to get the name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.