fork download
  1. <?php
  2.  
  3. function inverteData($data){
  4. if(count(explode("/",$data)) > 1){
  5. return implode("-",array_reverse(explode("/",$data)));
  6. }elseif(count(explode("-",$data)) > 1){
  7. return implode("/",array_reverse(explode("-",$data)));
  8. }
  9. }
  10.  
  11.  
  12. echo inverteData("01/10/1992");
  13. echo PHP_EOL;
  14. echo inverteData("1992-10-01");
  15. // your code goes here
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
1992-10-01
01/10/1992