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

  • Home
  • SEARCH
  • 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 9115091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:20:54+00:00 2026-06-17T04:20:54+00:00

I just started working on a project and before I begin I have a

  • 0

I just started working on a project and before I begin I have a few question about a peice
of code I need to put together, and how it will need to work.

This code will be generating serial numbers that when ran through an algorithm will equal
an identifier. The algorithm is nothing special.

The serial number will need to be broken up in to 4 sets of 5: (Preferably hexadecimal)

Example: 00A00-0B000-F00C0-0000D

The identifier will just be 1 set of numbers:

Example: 15456548

What I am looking to create is a script that could add(array_sum?) the hexadecimals in a serial number together, dived by 10 and equal the identifier(15456548). The script will need to create as many instances of the serial numbers as I tell it.

Program Example:

Identifier: 22807.4

How Many Serial Numbers To Make: 2

Serial Numbers:
45154-54587-58458-69875
55457-45584-18658-49578

(These serial numbers equal the identifier(22807.4) when added up and divided by 10)

I’m not sure if anyone could help me come up with something, or at least explain the process, but I’ve never built anything like this in PHP before.

  • 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-17T04:20:55+00:00Added an answer on June 17, 2026 at 4:20 am

    Another sample. You need to add few things to it. Hopefully you will realize them when you run the program.

    <?php 
        $num = '1234';
        $serNums = findSerialNum(1234, 5);
        echo var_export($serNums, true);
    
        function findSerialNumSingle($num)
        {
            $serialNum = array();
            $target = $num * 10;
            // select some heuristic. We have to generate 5 sets. How shall we 
            // distribute the numbers between the 5 sets? 
            // Obviously one set can exceed the num * 10 itself.
            // Lets select that as the heuristic, that the first number can be max that. 
            $remaining = $target;
            $soFar = 0;
            for($i = 0; $i < 5; $i++)
            {
                // select the entry that we would fill. Randomize it. 
                while(true)
                {
                    $idx = rand(0, 4);
                    if(!isset($serialNum[$idx])) // is the entry already filled in?
                        break;
                }
    
                $t = rand(0, $target - $soFar); // find number between 0 and remain number
                $serialNum[$idx] = $t;
                $soFar += $t;
            }
    
            // put serial number is proper format
            $s = '';
            for($i = 0; $i < 5; $i++)
            {
                $s .= sprintf('%05X', $serialNum[$i]) . '-';
            }
            return $s;
        }
        function findSerialNum($num, $numInstances)
        {
            $serNums = array();
            for($i = 0; $i < $numInstances; $i++)
            {
                while(true)
                {
                    // loop till you find a distinct serial number
                    $t = findSerialNumSingle($num);
                    if(array_search($t, $serNums) == FALSE)
                    {
                        $serNums[$i] = $t;
                        break;
                    }
                }
            }
            return $serNums;
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started working on one project where I need to compress and
I have just started working on an MVC project and things are going ok
I have just started working with a new Coldfusion project, well the project is
I have just started working on a project and I am using zend framework
I'm currently working on a school project in Eclipse (We have just started using
I just started working on my first Visual Studio project, and I imported all
I've just started working on an existing CakePHP project. I will be developing a
Just started working with Mercurial a few days ago and there's something I don't
I just started working on a small team of .NET programmers about a month
I'm about to begin working on a Accessibility project for Windows (targeting XP through

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.