Using binary to save switch data can save a lot of space, especially when storing a large amount of data. In general, three operations need to be implemented: [code snippets]
Using binary to save switch data can save a lot of space, especially when storing a large amount of data. In general, three operations need to be implemented: [code snippets]
Using binary to save switch data can save a lot of space, especially when storing a large amount of data. In general, there are three operations to be implemented:
$ Original = 345; // 101011001 function open ($ original, $ position) {$ data = 1 <$ position; return ($ original | $ data );} function close ($ original, $ position) {$ data = 1 <$ position; return ($ original &~ $ Data);} function get ($ original, $ position) {$ data = 1 <$ position; return ($ original & $ data)> 0? 1:0;} echo decbin ($ original), PHP_EOL; echo decbin (open ($ original, 2), '| open |', 2, PHP_EOL; echo decbin (close ($ original, 3), '| close |', 3, PHP_EOL; echo decbin (get ($ original, 4), '| get | ', 4, PHP_EOL; vagrant @ precise64:/var/www/test/curl $ php-f t. php 101011001101011101 | open | 2101010001 | close | 31 | get | 4,