Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a function that does the conversion the way you want. It could probably be done a lot more efficiently, but at least this gets it done:</p> <pre><code>function base_convert_0($number, $from_base, $to_base){ $numeric = base_convert($number, $from_base, 10); $result = ''; while($numeric &gt; $to_base){ $result = base_convert(($numeric - 1) % $to_base, 10, 36) . $result; $numeric = floor(($numeric - 1)/$to_base); } $result = base_convert(($numeric - 1), 10, 36) . $result; return $result; } </code></pre> <p><a href="http://ideone.com/86r1J6" rel="nofollow"><h3>5000 lines of output</h3></a></p> <p>80 lines shown here (<code>base_convert_0($i, 10, 36)</code>):</p> <pre><code>1: 0 2: 1 3: 2 4: 3 5: 4 6: 5 7: 6 8: 7 9: 8 10: 9 11: a 12: b 13: c 14: d 15: e 16: f 17: g 18: h 19: i 20: j 21: k 22: l 23: m 24: n 25: o 26: p 27: q 28: r 29: s 30: t 31: u 32: v 33: w 34: x 35: y 36: z 37: 00 38: 01 39: 02 40: 03 41: 04 42: 05 43: 06 44: 07 45: 08 46: 09 47: 0a 48: 0b 49: 0c 50: 0d 51: 0e 52: 0f 53: 0g 54: 0h 55: 0i 56: 0j 57: 0k 58: 0l 59: 0m 60: 0n 61: 0o 62: 0p 63: 0q 64: 0r 65: 0s 66: 0t 67: 0u 68: 0v 69: 0w 70: 0x 71: 0y 72: 0z 73: 10 74: 11 75: 12 76: 13 77: 14 78: 15 79: 16 80: 17 </code></pre> <p>I'm not sure if you need to reverse this, but that's the easy part anyway:</p> <pre><code>function base_convert_un0($number, $from_base, $to_base){ $as_string = strval($number); for($result = $j = 0, $i = strlen($as_string); $i--; $j++) $result += (base_convert($as_string{$i}, $from_base, 10) + 1)*pow($from_base, $j); return base_convert($result, 10, $to_base); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload