[PHP-NOTES] note 130277 added to function.decbin

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
Output a formatted binary number representation of a number:

<?php
function display_formatted_binary($n)
{
    $s = sprintf('%032b', $n);
    preg_match('#^(\d{8})(\d{8})(\d{8})(\d{8})$#', $s, $m);
    $m = array_slice($m, 1, 4);

    return implode('_', $m);
}

display_formatted_binary(1 << 14)
// 00000000_00000000_01000000_00000000
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 105.155.39.168)
----
Manual Page -- https://php.net/manual/en/function.decbin.php
Edit        -- https://main.php.net/note/edit/130277
Del: integrated  -- https://main.php.net/note/delete/130277/integrated
Del: useless     -- https://main.php.net/note/delete/130277/useless
Del: bad code    -- https://main.php.net/note/delete/130277/bad+code
Del: spam        -- https://main.php.net/note/delete/130277/spam
Del: non-english -- https://main.php.net/note/delete/130277/non-english
Del: in docs     -- https://main.php.net/note/delete/130277/in+docs
Del: other reasons-- https://main.php.net/note/delete/130277
Reject      -- https://main.php.net/note/reject/130277
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.