I have this function which converts numbers from decimal to binary.
<?php
function DecimalTOBinary($num)
{
$a = "";
$b = "";
$x = 0;
while ($num !=0)
{
$b .= $num % 2;
$num = $num /2;
}
/*
for($i = strlen($b) -1;$i >=0;$i--)
{
a .= substr($b,$i,$i +1);
}*/
return $b;
}
?>
My problem is that it will return the string:
010010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
I wish to return only:
0100101
How can I achieve this?