3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $subject = 'in the middle 9850112686331(14-15): for Rocco A & Stephanie'; $arr = preg_split('/[^a-z0-9\-()]/i', $subject); $candidates = []; for ($i = 0; $i < count($arr); $i++) { for ($j = $i; $j < count($arr); $j++) { $candidates[] = trim(implode(' ', array_slice($arr, $i, $j - $i + 1))); } } usort($candidates, function($a, $b) { return strlen($b) - strlen($a); }); foreach($candidates as $candidate){ echo $candidate . PHP_EOL; }
based on GdZQP
Output for 7.0.0 - 7.2.0
in the middle 9850112686331(14-15) for Rocco A Stephanie the middle 9850112686331(14-15) for Rocco A Stephanie middle 9850112686331(14-15) for Rocco A Stephanie in the middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for Rocco A 9850112686331(14-15) for Rocco A Stephanie in the middle 9850112686331(14-15) for Rocco the middle 9850112686331(14-15) for Rocco A the middle 9850112686331(14-15) for Rocco A the middle 9850112686331(14-15) for Rocco A the middle 9850112686331(14-15) for Rocco middle 9850112686331(14-15) for Rocco A middle 9850112686331(14-15) for Rocco A middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for middle 9850112686331(14-15) for Rocco the middle 9850112686331(14-15) for in the middle 9850112686331(14-15) in the middle 9850112686331(14-15) 9850112686331(14-15) for Rocco A 9850112686331(14-15) for Rocco A 9850112686331(14-15) for Rocco A middle 9850112686331(14-15) for 9850112686331(14-15) for Rocco the middle 9850112686331(14-15) the middle 9850112686331(14-15) middle 9850112686331(14-15) middle 9850112686331(14-15) 9850112686331(14-15) for for Rocco A Stephanie for Rocco A Stephanie 9850112686331(14-15) 9850112686331(14-15) Rocco A Stephanie in the middle A Stephanie for Rocco A for Rocco A for Rocco A for Rocco A for Rocco A for Rocco A the middle Stephanie Stephanie Stephanie for Rocco for Rocco Rocco A Rocco A Rocco A in the middle Rocco for the for in A A A
Output for 5.4.11 - 5.6.28
in the middle 9850112686331(14-15) for Rocco A Stephanie the middle 9850112686331(14-15) for Rocco A Stephanie middle 9850112686331(14-15) for Rocco A Stephanie in the middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for Rocco 9850112686331(14-15) for Rocco A Stephanie the middle 9850112686331(14-15) for Rocco A the middle 9850112686331(14-15) for Rocco A the middle 9850112686331(14-15) for Rocco A the middle 9850112686331(14-15) for Rocco middle 9850112686331(14-15) for Rocco A middle 9850112686331(14-15) for Rocco A middle 9850112686331(14-15) for Rocco A in the middle 9850112686331(14-15) for middle 9850112686331(14-15) for Rocco the middle 9850112686331(14-15) for in the middle 9850112686331(14-15) in the middle 9850112686331(14-15) 9850112686331(14-15) for Rocco A 9850112686331(14-15) for Rocco A 9850112686331(14-15) for Rocco A middle 9850112686331(14-15) for the middle 9850112686331(14-15) the middle 9850112686331(14-15) 9850112686331(14-15) for Rocco middle 9850112686331(14-15) middle 9850112686331(14-15) 9850112686331(14-15) for for Rocco A Stephanie for Rocco A Stephanie 9850112686331(14-15) 9850112686331(14-15) Rocco A Stephanie A Stephanie in the middle for Rocco A for Rocco A for Rocco A for Rocco A for Rocco A for Rocco A the middle Stephanie for Rocco for Rocco Stephanie Stephanie Rocco A Rocco A Rocco A in the middle Rocco for for the in A A A
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/4I7d1 on line 6
Process exited with code 255.