3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "php/127/typescript/12/jquery/120/angular/50"; preg_match_all("/([^\/]*?)\/(\d+)/", $str, $match); /* result: Array ( [0] => Array ( [0] => php/127 [1] => typescript/12 [2] => jquery/120 [3] => angular/50 ) [1] => Array ( [0] => php [1] => typescript [2] => jquery [3] => angular ) [2] => Array ( [0] => 127 [1] => 12 [2] => 120 [3] => 50 ) ) */ #then combine match[1] and match[2] $result = array_combine($match[1], $match[2]); /* result Array ( [php] => 127 [typescript] => 12 [jquery] => 120 [angular] => 50 ) */ print_r($result);
Output for 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.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
Array ( [php] => 127 [typescript] => 12 [jquery] => 120 [angular] => 50 )

preferences:
79.7 ms | 407 KiB | 5 Q