How can a PHP script be used to change the file extension from mp3 to m3u for streaming audio?
To change the file extension from mp3 to m3u for streaming audio using a PHP script, you can use the `rename()` function. This function renames a file or directory. You just need to specify the old file name (with the mp3 extension) and the new file name (with the m3u extension) as arguments to the function.
$oldFileName = 'audio.mp3';
$newFileName = 'audio.m3u';
if(rename($oldFileName, $newFileName)) {
echo "File extension changed successfully.";
} else {
echo "Error changing file extension.";
}
Keywords
Related Questions
- What are best practices for structuring conditional statements in PHP to ensure proper execution flow?
- How can SQL queries be optimized for statistical analysis in PHP applications?
- In what ways can MySQL be effectively utilized in a PHP project like a weekly calendar to assign activities to each calculated day?