How to print the bits of an integer in 32 bit format with PHP

1 Answer

0 votes
$number = 87361;


/*
 str_replace(
    array|string $search,
    array|string $replace,
    string|array $subject,
    int &$count = null
): string|array
*/


echo str_replace(" ", "0", sprintf("%32s", decbin($number))) . "\n";





/*
run:
     
00000000000000010101010101000001

*/

 



answered Dec 23, 2023 by avibootz

Related questions

2 answers 252 views
1 answer 129 views
1 answer 124 views
1 answer 110 views
1 answer 110 views
...