- substr: documentation ( source)
- strrev: documentation ( source)
- str_pad: documentation ( source)
<?php
$sourceId = '10131';
$idString = str_pad(strrev((string)$sourceId), 3, '0');
echo "/{$type}/" . substr($idString, 0, 2) . '/' . substr($idString, 2) . '/';