3v4l.org

run code in 300+ PHP versions simultaneously
<?php $line = "HELLO WORLD HOW ARE YOU I AM JUST FINE THANKS"; $plan = [9, 20]; var_dump(plan_split($line, $plan)); function plan_split(string $line, array $plan) : array { preg_match('/(.{' . implode('})(.{', $plan) . '})(.*)/s', $line, $m); array_shift($m); return $m; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
array(3) { [0]=> string(9) "HELLO " [1]=> string(20) "WORLD HOW ARE YOU " [2]=> string(21) "I AM JUST FINE THANKS" }

preferences:
107.27 ms | 404 KiB | 221 Q