Given a (long) string, ineterleave a fixed byte value after every existing byte.
Simple task with many solutions, but is there one that's quickest?
$buf = chr(1) x 1e6;; $s = time; $out = join( chr(0), unpack '(A1)*', $buf ) .chr(0); print time() - $s;; 11.3910000324249
In reply to Interleaving bytes in a string quickly by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |