1--TEST-- 2Test base_convert() - basic function tests base_convert() 3--FILE-- 4<?php 5$frombase = array(2,8,10,16,36); 6$tobase = array(2,8,10,16,36); 7 8$values = array(10, 9 27, 10 39, 11 039, 12 0x5F, 13 "10", 14 "27", 15 "39", 16 "5F", 17 "3XYZ" 18 ); 19 20for ($f= 0; $f < count($frombase); $f++) { 21 echo "\n...from base is ", $frombase[$f], "\n"; 22 for ($t= 0; $t < count($tobase); $t++) { 23 echo "......to base is ", $tobase[$t], "\n"; 24 for ($i =0; $i < count($values); $i++){ 25 $res = base_convert($values[$i],$frombase[$f],$tobase[$t]); 26 echo ".........value= ", $values[$i], " res = ", $res, "\n"; 27 } 28 } 29} 30?> 31 32--EXPECTF-- 33...from base is 2 34......to base is 2 35.........value= 10 res = 10 36.........value= 27 res = 0 37.........value= 39 res = 0 38.........value= 3 res = 0 39.........value= 95 res = 0 40.........value= 10 res = 10 41.........value= 27 res = 0 42.........value= 39 res = 0 43.........value= 5F res = 0 44.........value= 3XYZ res = 0 45......to base is 8 46.........value= 10 res = 2 47.........value= 27 res = 0 48.........value= 39 res = 0 49.........value= 3 res = 0 50.........value= 95 res = 0 51.........value= 10 res = 2 52.........value= 27 res = 0 53.........value= 39 res = 0 54.........value= 5F res = 0 55.........value= 3XYZ res = 0 56......to base is 10 57.........value= 10 res = 2 58.........value= 27 res = 0 59.........value= 39 res = 0 60.........value= 3 res = 0 61.........value= 95 res = 0 62.........value= 10 res = 2 63.........value= 27 res = 0 64.........value= 39 res = 0 65.........value= 5F res = 0 66.........value= 3XYZ res = 0 67......to base is 16 68.........value= 10 res = 2 69.........value= 27 res = 0 70.........value= 39 res = 0 71.........value= 3 res = 0 72.........value= 95 res = 0 73.........value= 10 res = 2 74.........value= 27 res = 0 75.........value= 39 res = 0 76.........value= 5F res = 0 77.........value= 3XYZ res = 0 78......to base is 36 79.........value= 10 res = 2 80.........value= 27 res = 0 81.........value= 39 res = 0 82.........value= 3 res = 0 83.........value= 95 res = 0 84.........value= 10 res = 2 85.........value= 27 res = 0 86.........value= 39 res = 0 87.........value= 5F res = 0 88.........value= 3XYZ res = 0 89 90...from base is 8 91......to base is 2 92.........value= 10 res = 1000 93.........value= 27 res = 10111 94.........value= 39 res = 11 95.........value= 3 res = 11 96.........value= 95 res = 101 97.........value= 10 res = 1000 98.........value= 27 res = 10111 99.........value= 39 res = 11 100.........value= 5F res = 101 101.........value= 3XYZ res = 11 102......to base is 8 103.........value= 10 res = 10 104.........value= 27 res = 27 105.........value= 39 res = 3 106.........value= 3 res = 3 107.........value= 95 res = 5 108.........value= 10 res = 10 109.........value= 27 res = 27 110.........value= 39 res = 3 111.........value= 5F res = 5 112.........value= 3XYZ res = 3 113......to base is 10 114.........value= 10 res = 8 115.........value= 27 res = 23 116.........value= 39 res = 3 117.........value= 3 res = 3 118.........value= 95 res = 5 119.........value= 10 res = 8 120.........value= 27 res = 23 121.........value= 39 res = 3 122.........value= 5F res = 5 123.........value= 3XYZ res = 3 124......to base is 16 125.........value= 10 res = 8 126.........value= 27 res = 17 127.........value= 39 res = 3 128.........value= 3 res = 3 129.........value= 95 res = 5 130.........value= 10 res = 8 131.........value= 27 res = 17 132.........value= 39 res = 3 133.........value= 5F res = 5 134.........value= 3XYZ res = 3 135......to base is 36 136.........value= 10 res = 8 137.........value= 27 res = n 138.........value= 39 res = 3 139.........value= 3 res = 3 140.........value= 95 res = 5 141.........value= 10 res = 8 142.........value= 27 res = n 143.........value= 39 res = 3 144.........value= 5F res = 5 145.........value= 3XYZ res = 3 146 147...from base is 10 148......to base is 2 149.........value= 10 res = 1010 150.........value= 27 res = 11011 151.........value= 39 res = 100111 152.........value= 3 res = 11 153.........value= 95 res = 1011111 154.........value= 10 res = 1010 155.........value= 27 res = 11011 156.........value= 39 res = 100111 157.........value= 5F res = 101 158.........value= 3XYZ res = 11 159......to base is 8 160.........value= 10 res = 12 161.........value= 27 res = 33 162.........value= 39 res = 47 163.........value= 3 res = 3 164.........value= 95 res = 137 165.........value= 10 res = 12 166.........value= 27 res = 33 167.........value= 39 res = 47 168.........value= 5F res = 5 169.........value= 3XYZ res = 3 170......to base is 10 171.........value= 10 res = 10 172.........value= 27 res = 27 173.........value= 39 res = 39 174.........value= 3 res = 3 175.........value= 95 res = 95 176.........value= 10 res = 10 177.........value= 27 res = 27 178.........value= 39 res = 39 179.........value= 5F res = 5 180.........value= 3XYZ res = 3 181......to base is 16 182.........value= 10 res = a 183.........value= 27 res = 1b 184.........value= 39 res = 27 185.........value= 3 res = 3 186.........value= 95 res = 5f 187.........value= 10 res = a 188.........value= 27 res = 1b 189.........value= 39 res = 27 190.........value= 5F res = 5 191.........value= 3XYZ res = 3 192......to base is 36 193.........value= 10 res = a 194.........value= 27 res = r 195.........value= 39 res = 13 196.........value= 3 res = 3 197.........value= 95 res = 2n 198.........value= 10 res = a 199.........value= 27 res = r 200.........value= 39 res = 13 201.........value= 5F res = 5 202.........value= 3XYZ res = 3 203 204...from base is 16 205......to base is 2 206.........value= 10 res = 10000 207.........value= 27 res = 100111 208.........value= 39 res = 111001 209.........value= 3 res = 11 210.........value= 95 res = 10010101 211.........value= 10 res = 10000 212.........value= 27 res = 100111 213.........value= 39 res = 111001 214.........value= 5F res = 1011111 215.........value= 3XYZ res = 11 216......to base is 8 217.........value= 10 res = 20 218.........value= 27 res = 47 219.........value= 39 res = 71 220.........value= 3 res = 3 221.........value= 95 res = 225 222.........value= 10 res = 20 223.........value= 27 res = 47 224.........value= 39 res = 71 225.........value= 5F res = 137 226.........value= 3XYZ res = 3 227......to base is 10 228.........value= 10 res = 16 229.........value= 27 res = 39 230.........value= 39 res = 57 231.........value= 3 res = 3 232.........value= 95 res = 149 233.........value= 10 res = 16 234.........value= 27 res = 39 235.........value= 39 res = 57 236.........value= 5F res = 95 237.........value= 3XYZ res = 3 238......to base is 16 239.........value= 10 res = 10 240.........value= 27 res = 27 241.........value= 39 res = 39 242.........value= 3 res = 3 243.........value= 95 res = 95 244.........value= 10 res = 10 245.........value= 27 res = 27 246.........value= 39 res = 39 247.........value= 5F res = 5f 248.........value= 3XYZ res = 3 249......to base is 36 250.........value= 10 res = g 251.........value= 27 res = 13 252.........value= 39 res = 1l 253.........value= 3 res = 3 254.........value= 95 res = 45 255.........value= 10 res = g 256.........value= 27 res = 13 257.........value= 39 res = 1l 258.........value= 5F res = 2n 259.........value= 3XYZ res = 3 260 261...from base is 36 262......to base is 2 263.........value= 10 res = 100100 264.........value= 27 res = 1001111 265.........value= 39 res = 1110101 266.........value= 3 res = 11 267.........value= 95 res = 101001001 268.........value= 10 res = 100100 269.........value= 27 res = 1001111 270.........value= 39 res = 1110101 271.........value= 5F res = 11000011 272.........value= 3XYZ res = 101100111010111011 273......to base is 8 274.........value= 10 res = 44 275.........value= 27 res = 117 276.........value= 39 res = 165 277.........value= 3 res = 3 278.........value= 95 res = 511 279.........value= 10 res = 44 280.........value= 27 res = 117 281.........value= 39 res = 165 282.........value= 5F res = 303 283.........value= 3XYZ res = 547273 284......to base is 10 285.........value= 10 res = 36 286.........value= 27 res = 79 287.........value= 39 res = 117 288.........value= 3 res = 3 289.........value= 95 res = 329 290.........value= 10 res = 36 291.........value= 27 res = 79 292.........value= 39 res = 117 293.........value= 5F res = 195 294.........value= 3XYZ res = 183995 295......to base is 16 296.........value= 10 res = 24 297.........value= 27 res = 4f 298.........value= 39 res = 75 299.........value= 3 res = 3 300.........value= 95 res = 149 301.........value= 10 res = 24 302.........value= 27 res = 4f 303.........value= 39 res = 75 304.........value= 5F res = c3 305.........value= 3XYZ res = 2cebb 306......to base is 36 307.........value= 10 res = 10 308.........value= 27 res = 27 309.........value= 39 res = 39 310.........value= 3 res = 3 311.........value= 95 res = 95 312.........value= 10 res = 10 313.........value= 27 res = 27 314.........value= 39 res = 39 315.........value= 5F res = 5f 316.........value= 3XYZ res = 3xyz