3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $id = '01110413'; $ltr = array('00' => 'A', '01' => 'B', '010' => 'X', '03' => 'C', '04' => 'D'); ksort($ltr); foreach ($ltr as $search=>$replace) { $id = str_replace($search, $replace, $id); } var_dump($ltr);
Output for 4.3.0 - 7.1.0
array(5) { ["00"]=> string(1) "A" ["01"]=> string(1) "B" ["03"]=> string(1) "C" ["04"]=> string(1) "D" ["010"]=> string(1) "X" }