3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'aktuell/blog/cat1/cat2/cat3'; $uri_arr = explode("/",$str); $cat = array(); array_map(function($v) use (&$cat){ preg_match('/^cat\d$/',$v,$matches); if(count($matches) > 0){ $cat[] = $matches[0]; } },$uri_arr); print_r($cat);

preferences:
143.33 ms | 407 KiB | 5 Q