Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. $Medio=''; //variable to handle the result
  2.  
  3. $MedioPago='12345'; //variable with numbers given
  4.  
  5. $chars = str_split($MedioPago); //split the numbers
  6.  
  7.  
  8. foreach($chars as $char)
  9. {
  10. if($char=='1')
  11. {
  12. $Medio.='"codigo": "01",'.PHP_EOL;
  13. }
  14. else if($char=='2')
  15. {
  16. $Medio.='"codigo": "02",'.PHP_EOL;
  17. }
  18. else if($char=='3')
  19. {
  20. $Medio.='"codigo": "03",'.PHP_EOL;
  21. }
  22. else if($char=='4')
  23. {
  24. $Medio.='"codigo": "04",'.PHP_EOL;
  25. }
  26. else if($char=='5')
  27. {
  28. $Medio.='"codigo": "05",'.PHP_EOL;
  29. }
  30. }
  31.  
  32. $Medio = rtrim($Medio,',');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement