What are the advantages and disadvantages of storing data in a text file versus using a database for a small project?

Storing data in a text file for a small project can be advantageous because it is simple, lightweight, and easy to implement. However, text files may not be as efficient for querying and manipulating data compared to using a database. Databases offer better organization, indexing, and querying capabilities, but they may be overkill for a small project.

// Example of storing data in a text file
$data = "John,Doe,30\nJane,Smith,25";
file_put_contents('data.txt', $data);

// Example of reading data from a text file
$data = file_get_contents('data.txt');
$lines = explode("\n", $data);
foreach($lines as $line){
    $parts = explode(",", $line);
    echo "Name: $parts[0] $parts[1], Age: $parts[2] <br>";
}