How do I capture PHP output into a variable?

后端 未结 4 1789
猫巷女王i
猫巷女王i 2020-11-27 04:04

I\'m generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. I also want to be able to show the user the XML before han

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 04:42

    You could try this:

    
    
      XML Document
      
      
    XMLDoc;
    
    $fruits = array('apple', 'banana', 'orange');
    
    foreach($fruits as $fruit) {
      $string .= "\n    ".$fruit."";
    }
    
    $string .= "\n  
    ";
    ?>
    
    
    
    ", ">", $string))?>

提交回复
热议问题