简体   繁体   中英

Insert character after each 8 character

i have one string called dvojka value is 0110111101101010 It's a binary. And I need to insert character "-" after each 8 chracter, because one character is 8 bits. Is there some way using PHP? Thank you.

wordwrap ?

$output = wordwrap($dvojka,8,'-',true);

The 3rd parameter is required as the string your breaking up doesn't have any whitespace

Example : http://codepad.org/sbhBe5pb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM