Zest.

PHP: Read a file

A short, tested PHP example for read a file. Copy it and adjust the names and paths for your project.

PHP
$text = file_get_contents("data.txt");
$lines = file("data.txt", FILE_IGNORE_NEW_LINES);
file_put_contents("out.txt", "hello\n", FILE_APPEND);

Find it in Zest

Search for “php read a file” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More PHP examples

All PHP examples