How to generate XML file dynamically using PHP?

前端 未结 7 2251
失恋的感觉
失恋的感觉 2020-11-22 00:32

I have to generate a xml file dynamically at runtime. Please help me in generating the below XML file dynamically using PHP.



        
7条回答
  •  隐瞒了意图╮
    2020-11-22 00:51

    With FluidXML you can generate your XML very easly.

    $tracks = fluidxml('xml');
    
    $tracks->times(8, function ($i) {
        $this->add([
            'track' => [
                'path'  => "song{$i}.mp3",
                'title' => "Track {$i} - Track Title"
            ]
        ]);
    
    });
    

    https://github.com/servo-php/fluidxml

提交回复
热议问题