I'm just starting out with php/mysql. I'm looking for tutorials or assistance on ways to go about accomplishing what I was doing with .asp's FileSystem Object. Namely, reading, and writing text files.
I am looking for an efficient way to read a text file and replace certain sections with data from the database. Right now I'm just working on the php side of the equation.
Is there a more efficient way to do this?
//define source_content file
$filename = "templ.htm";
//open source_content for reading
$fp = fopen( $filename,"r");
//read source_content into var
$source_content = fread($fp, 80000);
//close
fclose( $fp );
//place strings to search for into an array
$search_array = array("xx1", "xx2", "xx3", "xx4", "xx5");
//place replacement strings into an array
$replace_array = array("yy1", "yy2", "yy3", "yy4", "yy5");
//
$new_content = str_replace($search_array, $replace_array, $source_content);
echo $new_content;
I'm just looking for advice or pointers or tutorials.
TIA