1,php reads data line-by-row from the text and saves it to the data set. Using fopen to read text content, the line-reading text is $majorid = Trim (fgets ($rfile, 4096));.
$rfile = fopen ("Cate_id.txt", "R"), if ($rfile) {while (!feof ($rfile)) { $majorId = Trim (fgets ($rfile, 4096)); c3/> $majorName = Categorynamespace::getmajorcategorybyid ($majorId); if (! $majorName) { $majorName = Categorynamespace::getminorcategorybyid ($majorId); } $majorArray [$i] [' id '] = $majorId; $majorArray [$i] [' name '] = $majorName [' name ']; $i + +; } Fclose ($rfile);}
2, exports the number of arrays to text, splits the contents of the array into strings, and exports the strings to text.
$MAJORSTR = "Majorid". " \ t "." Majorname "." \ n "; $wfile = ' Cate_result.txt '; foreach ($majorArray as $major) { $majorStr = Trim ($majorStr. $major [' ID '])." \ t ". Trim ($major [' name '])." \ n ";} File_put_contents ($wfile, $MAJORSTR);
PHP reads data from text, processes results and then imports into text