|
|
|
<?
/* Filename: massreplace.inc
* Created: 07.21.98
* Author: Darrell Brogdon (dbrogdon@sagenetworks.com)
* Usage: massreplace(STRING1, STRING2, FILE);
*
* Description: Similar to the Unix 'massreplace' command, this
* function takes the value of "STRING2" and replaces
* every instance of "STRING1" with STRING2's value in
* "FILE".
*/
/* $Id: massreplace.inc,v 1.0 1998/07/21 23:04:12 darrell Exp $ */
Function massreplace($string1, $string2, $filename) {
$fd = fopen( $filename, "r" );
$contents = fread( $fd, filesize( $filename ) );
$size = filesize( $filename );
fclose( $fd );
$massreplace = ereg_replace($string1, $string2, $contents);
$fd = fopen($filename, "w");
fputs($fd, $massreplace, $size);
fclose($fd);
}
?>
|
|
| Show Source with Line Numbers Categories : PHP, Regexps, Filesystem | | | Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS) | | | I need a trim function/regexp that will trim all " " from the ends of a string. Categories : Regexps, PHP, Strings | | | Simple way to replace a variable value in a .conf (.ini) file using a
webbrowser - the first stage of a complete universal configuration editor Categories : PHP, Regexps, Code Editors, Filesystem | | | How to ifconfig down/up a list of IP's Categories : Arrays, Strings, Filesystem, PHP | | | columned txt file to array()? Categories : Arrays, Strings, Regexps, PHP | | | Read a file with strings and create a new file with the
first half of each string Categories : PHP, Strings, Filesystem | | | Grab images from one or more URLs and save them to a specified local directory. Categories : PHP, Filesystem, Strings, Arrays | | | Making sure a string containes only digits or no digits. Categories : Strings, PHP, Regexps | | | String Replacement and speed consideration
Categories : PHP, Strings, Regexps | | | Finding numbers within a string Categories : PHP, Regexps, Strings | | | Compare two texts and display a block of text with the differences between them. Categories : PHP, PHP Classes, Filesystem, Strings, Arrays | | | Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays, Filesystem, Variables, Strings, PHP | | | how can I read the entire contents of a file into a string? Categories : Filesystem, Strings, PHP | | | How to find the name of the current file? Categories : PHP, Filesystem, Strings | |
|
|
|