3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ "age<21,length>10,height<>10,width!=100,name='Emma Einarsson' or it can be words time>=10,clouds<=4", "age < 21, length > 10, height <> 10, width != 100, name = 'Emma Einarsson' or it can be words time >= 10, clouds <= 4", "My name is Emma and i have a dillemma, what's the distance between 'New York' and 'Athene' ?", "'New York' and London at the start and end with Paris and 'Los Angeles'" ]; foreach ($strings as $string) { var_export(preg_match_all("~\B'\K(?:[^']+)|\b[a-z']+\b|\d+|[<>!=?]+~i", $string, $out) ? $out[0] : 'fail'); echo "\n"; }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
array ( 0 => 'age', 1 => '<', 2 => '21', 3 => 'length', 4 => '>', 5 => '10', 6 => 'height', 7 => '<>', 8 => '10', 9 => 'width', 10 => '!=', 11 => '100', 12 => 'name', 13 => '=', 14 => 'Emma Einarsson', 15 => 'or', 16 => 'it', 17 => 'can', 18 => 'be', 19 => 'words', 20 => 'time', 21 => '>=', 22 => '10', 23 => 'clouds', 24 => '<=', 25 => '4', ) array ( 0 => 'age', 1 => '<', 2 => '21', 3 => 'length', 4 => '>', 5 => '10', 6 => 'height', 7 => '<>', 8 => '10', 9 => 'width', 10 => '!=', 11 => '100', 12 => 'name', 13 => '=', 14 => 'Emma Einarsson', 15 => 'or', 16 => 'it', 17 => 'can', 18 => 'be', 19 => 'words', 20 => 'time', 21 => '>=', 22 => '10', 23 => 'clouds', 24 => '<=', 25 => '4', ) array ( 0 => 'My', 1 => 'name', 2 => 'is', 3 => 'Emma', 4 => 'and', 5 => 'i', 6 => 'have', 7 => 'a', 8 => 'dillemma', 9 => 'what\'s', 10 => 'the', 11 => 'distance', 12 => 'between', 13 => 'New York', 14 => 'and', 15 => 'Athene', 16 => '?', ) array ( 0 => 'New York', 1 => 'and', 2 => 'London', 3 => 'at', 4 => 'the', 5 => 'start', 6 => 'and', 7 => 'end', 8 => 'with', 9 => 'Paris', 10 => 'and', 11 => 'Los Angeles', )

preferences:
166.28 ms | 412 KiB | 5 Q