fork(2) download
  1. <?php
  2.  
  3. $input = '1ab2v3g4de';
  4. $length = \strlen($input);
  5. $numerics = [];
  6.  
  7. for ($i = 0; $i < $length; ++$i) {
  8. if (\is_numeric($input[$i])) {
  9. $numerics[] = [$i => $input[$i]];
  10. }
  11. }
  12.  
  13. $numLastIndex = \count($numerics) - 1;
  14.  
  15. foreach ($numerics as $key => $numericData) {
  16. $newKey = $numLastIndex - $key;
  17. $input[\key($numericData)] = $numerics[$newKey][\key($numerics[$newKey])];
  18. }
  19.  
  20. \var_dump($input);
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
string(10) "4ab3v2g1de"