fork download
  1. <?php
  2.  
  3. function shift_calc($x, $y) {
  4. return $x != '0' ? $x : $y;
  5. };
  6.  
  7. function shift_sum($am, $pm) {
  8. return implode(array_map('shift_calc', str_split($am), str_split($pm)));
  9. };
  10.  
  11. $result = shift_sum('A00A00A', '0P000P0');
  12.  
  13. var_dump($result);
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
string(7) "AP0A0PA"