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