Created
October 28, 2011 19:51
-
-
Save redcap3000/1323364 to your computer and use it in GitHub Desktop.
Number Base Conversion Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ronaldo Barbachano October 2011 | |
// Created out of a need to compress integer values in couch databases. Php 5.3 will allow up to 36 bit bases, | |
// which results in the smallest integer representation. | |
//To convert to default base, of 8, just provide | |
// number_base::number_convert(1); | |
// encodes 1 into base 32 number | |
// number_base::num_convert(1,32); | |
// decodes base 32 number into 8 | |
// number_base::num_convert(<base 32 number>,8,32); | |
class number_base{ | |
public static function number_convert($integer,$end_base = 8,$start_base = 10){ | |
// created to help assist in the creation of creating _id fields in couch databases | |
// based on integer values | |
return base_convert($integer, $start_base,$end_base); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment