diff --git a/rebuild.php b/rebuild.php index 3236845..2715390 100644 --- a/rebuild.php +++ b/rebuild.php @@ -121,9 +121,10 @@ function text2html($sz) { $splitInside = function($begin, $end, $sz) { $parts = explode($begin, $sz); if (count($parts) == 1) return [$sz]; + $ret = [$parts[0]]; - foreach($parts as $part) { - $inner = explode($end, $part, 2); + for($i = 1, $e = count($parts); $i !== $e; ++$i) { + $inner = explode($end, $parts[$i], 2); $ret = array_merge($ret, $inner); } return $ret; @@ -138,8 +139,7 @@ function text2html($sz) { }; $htmlSections = $splitInside('', '', $sz); - return $oddEven($htmlSections, $sectionFmt, $identity); - + return $oddEven($htmlSections, $identity, $sectionFmt); } function array_decimate($array, $total, $partno) {