3v4l.org

run code in 300+ PHP versions simultaneously
<?php // convert decimal to base 2 without using base_convert or printf $base = 2; $num = 23; while( $num > 0) { $arr[] = $num % $base; // store remainder in array $num = floor($num/$base); // no integer division } var_dump($arr); $wrong = join('',$arr); var_dump($wrong); $cat = join('',array_reverse($arr)); var_dump($cat); printf("%b",$num);

preferences:
58.89 ms | 402 KiB | 5 Q