omg*_*omg 2 php binary decimal
例如:
$result = func(14);
Run Code Online (Sandbox Code Playgroud)
本$result应该是:
array(1,1,1,0)
Run Code Online (Sandbox Code Playgroud)
怎么实现这个func?
decbin 会产生一个二进制字符串:
echo decbin(14); # outputs "1110"
array_map('intval', str_split(decbin(14))) # acomplishes the full conversion
Run Code Online (Sandbox Code Playgroud)