rename a json file in php

To rename a JSON file in PHP, you can use the rename() function provided by PHP. Here's an example code:

main.php
$oldFileName = "old_file.json";
$newFileName = "new_file.json";

if(rename($oldFileName, $newFileName)){
    echo "File renamed successfully.";
}else{
    echo "File renaming failed.";
}
187 chars
9 lines

In this example, we're renaming the file named "old_file.json" to "new_file.json". The rename() function takes two arguments - the current file name and the new file name - and returns true if the renaming was successful or false otherwise.

related categories

gistlibby LogSnag