3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function makeCatList($param){ $arResult = array(); $s = array("@[aаА]@u","@[bбБ]@u","@[cсС]@u","@[dдД]@u","@[eеЕ]@u","@[tтТ]@u","@[rрР]@u","@TB@u"); $r = array("A","B","C","D","E","T","r","Tb"); $param["string"] = preg_replace($s, $r, $param["string"]); if(preg_match_all("/((?:[A-D]1)|(?:[A-D][E]?)|(Tr|Tb))/u", $param["string"], $mCats)){ sort($mCats[0]); return $mCats[0]; } else return false; } $a = makeCatList(array("string"=>"dвсАв1beс1edeTr")); print_r($a);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => A [1] => BE [2] => C [3] => C1 [4] => D [5] => DE [6] => Tr )