<p>I have sets of 5, 6 and 7 digit numbers. I need them to be displayed in the 000/000/000 format. So for example: </p>

<p>12345 would be displayed as 000/012/345 </p>

<p>and </p>

<p>9876543 would be displayed as 009/876/543</p>

<p>I know how to do this in a messy way, involving a series of if/else statements, and strlen functions, but there has to be a cleaner way involving regex that Im not seeing.</p>

sprintf and modulo is one option
```
```
function formatMyNumber($num)
{
    return sprintf('%03d/%03d/%03d',
                   $num / 1000000,
                  ($num / 1000) % 1000,
                   $num % 1000);
}
```
```