Nov 09 2009

Load File into a String

Category: PhpGiulio Pons @ 1:08 pm

Simple old function to load a file into a string.


$s = loadStrFile("file.txt");

function loadStrFile($filename) {
	$handle = fopen ($filename, "rb");
	$contents = fread ($handle, filesize ($filename));
	fclose ($handle);
	return $contents;
}
Share

Related posts:

  1. How many users are connected?
  2. Copying remote files on your server with PHP
  3. Truncate string preserving some words in PHP
  4. Get file name in javascript
  5. Sending HTML emails with attachment with PHP

Tags:

One Response to “Load File into a String”

  1. seeal says:

    Really nice blog, nice snippet codes, thx 4 sharing :D

Leave a Reply