How do I only save file name and add 4 extra lines when saving to a text file.

MPG Radio

n00b
Joined
Oct 10, 2021
Messages
2
Not Sure where or if listing this is relative in this forum. Being new uncertain.

but here goes..PHP code question....i think "basename" is the right direction..

PHP:
$folder = '../video';
$data = implode(PHP_EOL, glob($folder . "/*.mp4"));

$my_file = 'schedule.txt';
$handle = fopen($my_file, 'w') or die("Cannot open file: ". $my_file);
fwrite($handle, $data);
fclose($handle);

right now the output is
./video/Clover Hill Official Music Video Leaves A Scar.mp4
I need it o be
Clover Hill Official Music Video Leaves A Scar
with the addition of 4 extra blank lines at the top
 

Attachments

  • schedule.jpg
    schedule.jpg
    108.9 KB · Views: 0
Not Sure where or if listing this is relative in this forum. Being new uncertain.

but here goes..PHP code question....i think "basename" is the right direction..

PHP:
$folder = '../video';
$data = implode(PHP_EOL, glob($folder . "/*.mp4"));

$my_file = 'schedule.txt';
$handle = fopen($my_file, 'w') or die("Cannot open file: ". $my_file);
fwrite($handle, $data);
fclose($handle);

right now the output is
./video/Clover Hill Official Music Video Leaves A Scar.mp4
I need it o be
Clover Hill Official Music Video Leaves A Scar
with the addition of 4 extra blank lines at the top
Like this?
Code:
.
 .
 .
 .
Really long filename.mp4
(Ignore the dots...)
Going to want something like this:
Code:
/r/n/r/n/r/n/r/n$filename
As the input to whatever function you use in php to write to a file descriptor.
 
Back
Top