shrink integers with php
function chr_enc( $id ) { $c = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $id = (string)$id; for( $i = 0; $i < strlen( $id ); $i++ ) { $x .= $id{$i}; if( $x > 9 && $x <= ( strlen( $c ) + 9 ) ) { $n .= $c{$x-10}; $x = ''; } elseif( $x > strlen( $c ) + 10 || $x == '0' || $i == ( strlen( $id ) - 1 ) ) { $n .= $x; $x = ''; } } return $n;}function chr_dec( $id ) { $c = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; for( $i = 0; $i < strlen( $id ); $i++ ) { $n .= ( !is_numeric( $id{$i} ) ) ? ( strpos( $c, $id{$i} ) + 10 ) : $id{$i}; } return $n;}
example:
212408898 => lo08898
30028247 => u0so7
11222207 => bmm07
94070738 => 94070738
81071369 => 81071A9
197309119 => j73091j
15018738 => f0i738
78584770 => 78WL70
191854002 => jiS002
188192516 => i8192P6
65437343 => 65H73H
124061870 => cEZ870
207003851 => k700CP
218431612 => l84vZ2
5688664 => U88664
162528033 => gps0x
57489904 => VM9904
89269087 => 89q9087
193413083 => jyd083
144121183 => eFli3
218427866 => l84r866
57912246 => V91mK
229392376 => m9392B6
56443324 => UIxo
34996219 => ...
