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

1 Answer

0 votes
$number = 441;


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


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





/*
run:
     
0000000110111001

*/

 



answered Dec 23, 2023 by avibootz

Related questions

1 answer 105 views
1 answer 138 views
2 answers 134 views
1 answer 112 views
1 answer 96 views
...