Question

I want to get blog01.xml from data01.xml, blog02.xml from data02.xml and so on. I'm trying with the following code, but it doesn't work. What is wrong?

<?php
$v = 1;
do {

    $file = "RAW/" . 'data[$v].xml';
    $postxml = @file_get_contents($file);

    $postxml = str_replace("-", " ", $postxml);

    file_put_contents("XML/" . 'blog0[$v].xml', $postxml);
    $v++;
} while($v<=5);
?>
Was it helpful?

Solution

Use

file_put_contents('XML/blog0'.$v.'.xml', $postxml);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top