Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. <?php
  2. $string = trim(fgets(STDIN));
  3.  
  4.  
  5. function stringToXML($string){
  6. $list = explode(',', $string);
  7. echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  8. echo '<quiz>' . "\n";
  9. for($i = 0; $i < count($list); $i+=2){
  10. echo ' <question>' . "\n";
  11. echo " " . trim($list[$i]) . "\n";
  12. echo ' </question>' . "\n";
  13. echo ' <answer>' . "\n";
  14. echo " " . trim($list[$i+1]) . "\n";
  15. echo ' </answer>' . "\n";
  16. }
  17. echo '</quiz>';
  18. }
  19.  
  20. stringToXML($string);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement