I have a string contains sequences of 0 and 1. I need to replace all zero sequences whose length less than 5, into number 1 with same length. The zero sequences with length 5 or more should be left as is.
For example
source : 11000001100010011000001
result : 11000001111111111000001
<?php
$string = '11111000011100000110010';
$pattern = '/0{1,4}/i';
$replacement = '1'; // what should I put here?
echo preg_replace($pattern, $replacement, $string);
?>
Thanks