hello

i was creating a script who will read a text file and create mp3 files from lines name , but i had a problem , php wont write php files it give me this warnning message

Warning: rename(0.txt,Aa Gale Lag Ja - Tera Mujhse Hai .mp3): Invalid argument in c:\gamesrecord\000\mpror.php on line 21

this is my code :

<?php 
$lines = file('file.txt');
 $l_count = count($lines);
 
 for($x = 0; $x< $l_count; $x++)
{
  $po = $lines[$x] ; 
  $ourFileName = "$x.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);

rename("$x.txt","$po.mp3");


echo $ourFileName ; 
 
 }


?>

pls help
and thank you ;)

hahaah i have solution , the problem was the blanc space , i used a php function who delete it rtrim("$file");

so the code is :

<?php 
$lines = file('file.txt');
 $l_count = count($lines);
 
 for($x = 0; $x< $l_count; $x++)
{
  $po = $lines[$x] ; 
  $ourFileName = "$x.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
$mo = rtrim("$po");
rename("$x.txt","$mo.mp3");


echo $ourFileName ; 
 
 }


?>

have a good day

now lets create the fake mp3s file :twisted:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.