submitted by:
PHP: File to String - Simple
Reading a file to a string couldn't be easier than using the file_get_contents() function. Simple pass the name of the file (with path) and optional parameters (see documentation link).
code snippet:
<?php
// ********************************
// basic example
$homepage = file_get_contents('http://www.example.com/');
$localfile = file_get_contents('config.ini');
// ********************************
// Get a file using the include path
// Below PHP 5
$file = file_get_contents('./people.txt', true);
// PHP 5 and above
$file = file_get_contents('./people.txt', FILE_USE_INCLUDE_PATH);
?>
notes:
You can also set the offset and amount of text to read



