Home > Blockchain >  Checking the ID in the specified range of numbers
Checking the ID in the specified range of numbers

Time:12-18

I have a table containing 10 million file links, each file has its own unique ID. I want to save every 10,000 files in one folder.

This is the ID of the files:

1
2
3
4
5
.
.
.
10000000

This is my range of numbers:

0
10000
20000
30000
40000
50000
.
.
.
10000000

Now how can I determine the range by getting each ID?

For example, if the ID of the file is 5000, it should be placed in folder 0. If the ID is 19000, it should be placed in the 10000 folder

id    ----------> folder
5000  ----------> 0
19000 ----------> 10000
21000 ----------> 20000

I want this work to be done with PHP language

CodePudding user response:

You can achieve this using basic function floor:

<?php
function getFolder(int $id) {
    return  floor($id/10000) * 10000;
}

https://phpize.online/s/AU

  • Related