Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Checking the ID in the specified range of numbers

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

You can achieve this using basic function floor:

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

https://phpize.online/s/AU

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading