Skip to content

Instantly share code, notes, and snippets.

@sarathlal-old
Last active June 2, 2016 12:43
Show Gist options
  • Save sarathlal-old/6de6dfd525f4cb5c3017a92ddcc385ba to your computer and use it in GitHub Desktop.
Save sarathlal-old/6de6dfd525f4cb5c3017a92ddcc385ba to your computer and use it in GitHub Desktop.
Add string on each line of a file content before or after the content. Just insert the file to be processed on the same directory in our server and call our script via browser.
<?php
$handle = fopen("file.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
// process the line read.
echo "Text Before - " . $line . " - Text After<br>";
}
fclose($handle);
} else {
echo "Error!<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment