fork download
  1. <?php
  2.  
  3. $str = '12-345-67-89-10';
  4. echo $str, PHP_EOL;
  5. echo preg_replace('/-/', '!', $str, 2), PHP_EOL;
  6. echo strrev(preg_replace('/-/', '!', strrev($str), 2)), PHP_EOL;
  7.  
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
12-345-67-89-10
12!345!67-89-10
12-345-67!89!10