$file = 'example.txt'; $data = 'This is some example data.'; file_put_contents($file, $data);
$file = 'example.txt'; $data = array('apple', 'banana', 'cherry'); file_put_contents($file, implode("\n", $data));
$file = 'example.txt'; $data = 'This is some more data.'; file_put_contents($file, $data, FILE_APPEND);This will append the string "This is some more data." to the existing file named `example.txt`. The `file_put_contents()` function is part of the PHP core library, so no additional packages or libraries are required.