Große Dateien verarbeiten in PHP
Große Dateien zeilenweise in PHP verarbeiten
Hinweis: Ich mache mal wieder bei einem SEO Contest mit. Die Seite
Revierphone
ist meine Seite zum SEO Contest. Wer mich unterstützen möchte, kann die Seite http://m-software.de/revierphone/
mit dem Linktext Revierphone verlinken.
Vielen Dank im Voraus
/************************************************* Zeilenweise Verarbeitung von Textdateien in PHP Author: Michael JentschCopyright (c): 2006 - all rights reserved Version: 1.01 * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You may contact the author of by e-mail at: M.Jentsch@web.de The latest version can be obtained from: http://www.m-software.de/ *************************************************/ $filename = \"urls.txt\"; $readsize = 1024*1024; // 1MB $linebreak = \"\\n\"; $rest = \"\"; $handle = fopen ($filename, \"r\"); $linebreaksize = strlen ($linebreak); while (!feof($handle)) { $contents = $rest . fread($handle, $readsize); $rest = substr (strrchr ($contents, $linebreak), $linebreaksize); $contents = substr($contents, 0, strlen ($contents) - strlen ($rest) - $linebreaksize); $lines = split ($linebreak, $contents); $anz = count ($lines); for ($i = 0; $i < $anz; $i++) { $line = $lines[$i]; // Hier kann man dann etwas mit der aktuellen Zeile machen } } fclose ($handle); exit (0);
Hat Ihnen dieser Beitrag geholfen? Dann speichern Sie Ihne doch bei diesen Diensten:
Wenn Ihnen diese Informationen zu "Große Dateien verarbeiten in PHP" gefallen haben, Sie Anregungen oder Kritik haben, dann schreiben Sie mir doch einfach eine E-Mail an M.Jentsch@web.de.




