Tango.info base20: Difference between revisions

From tango.info wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<pre>
<pre>
function tif_num2consonants($number, $frombase=10 , $tobase=20){
function tif_num2consonants($number, $frombase=10 , $tobase=20){
//convert to base 20
$r=base_convert ($number, $frombase , $tobase );
$r=base_convert ($number, $frombase , $tobase );
$r=str_split($r);
//no vowel, no l
//convert 0-j to b-z, no vowel, no l
$char_0j_to_bz=array(
$char_0j_to_bz=array(
0=>"b",
0=>"b",
Line 27: Line 27:
"j"=>"z"
"j"=>"z"
);
);
 
$r=str_split($r);
$r_new=array();
$r_new=array();
foreach ($r as $k =>$v){
foreach ($r as $k =>$v){

Revision as of 2011-04-08T19:39:23

function tif_num2consonants($number, $frombase=10 , $tobase=20){
	//convert to base 20
	$r=base_convert ($number, $frombase , $tobase );
	
	//convert 0-j to b-z, no vowel, no l
	$char_0j_to_bz=array(
	0=>"b",
	1=>"c",
	2=>"d",
	3=>"f",
	4=>"g",
	5=>"h",
	6=>"j",
	7=>"k",
	8=>"m",
	9=>"n",
	"a"=>"p",
	"b"=>"q",
	"c"=>"r",
	"d"=>"s",
	"e"=>"t",
	"f"=>"v",
	"g"=>"w",
	"h"=>"x",
	"i"=>"y",
	"j"=>"z"
	);

	$r=str_split($r);
	$r_new=array();
	foreach ($r as $k =>$v){
		$v_new=$char_0j_to_bz[$v];
		$r_new[$k]=$v_new;
	}
	$r_new=implode($r_new);
	//$tmp=array_flip($tmp);
	
	return $r_new;
}