Verfasst: 02.04.2006 15:45
Dann machste ne WHILE Schleife und machst alles manuell mit substr() und strpos()
Grüße
Dennis
Grüße
Dennis
phpBB.de - Die deutsche phpBB-Community
https://www.phpbb.de/community/
Code: Alles auswählen
while( list( $id, $text) = each( $array) )
{
$text = stripslashes($text);
if( !empty($text) or $text = " " )
{
// Ausführen wenn Zeile nicht leer ist
}
}
Code: Alles auswählen
<?php
$datei = "dateiname.htm";
$text = file($datei);
for ($i = 0; $i < count($text); $i++)
{
if( empty($text[$i]) || $text[$i] == " " || $text[$i] == "" || $text[$i] == " /n" || $text[$i] == "/n")
{
unset($text[$i]);
}
else
{
$text[$i] = preg_replace("/\<(.*?)\>/si", "", $text[$i]);
$text[$i] = str_replace(" ", "", $text[$i]);
$text[$i] = str_replace("<!--", "", $text[$i]);
$text[$i] = str_replace("var thispagename = self.location.href.substring(self.location.href.lastIndexOf('/')+1,self.location.href.length);", "", $text[$i]);
$text[$i] = str_replace("if(!parent.mainFrame)", "", $text[$i]);
$text[$i] = str_replace("{", "", $text[$i]);
$text[$i] = str_replace("}", "", $text[$i]);
$text[$i] = str_replace('window.location.href="index.html?"+thispagename;', "", $text[$i]);
$text[$i] = str_replace("//-->", "", $text[$i]);
$text[$i] = trim($text[$i]);
}
}
print_r($text);
?>
Code: Alles auswählen
<?php
$datei = "dateiname.htm";
$text = file($datei);
for ($i = 0; $i < count($text); $i++)
{
$text[$i] = preg_replace("/\<(.*?)\>/si", "", $text[$i]);
$text[$i] = str_replace(" ", "", $text[$i]);
$text[$i] = str_replace("<!--", "", $text[$i]);
$text[$i] = str_replace("var thispagename = self.location.href.substring(self.location.href.lastIndexOf('/')+1,self.location.href.length);", "", $text[$i]);
$text[$i] = str_replace("if(!parent.mainFrame)", "", $text[$i]);
$text[$i] = str_replace("{", "", $text[$i]);
$text[$i] = str_replace("}", "", $text[$i]);
$text[$i] = str_replace('window.location.href="index.html?"+thispagename;', "", $text[$i]);
$text[$i] = str_replace("//-->", "", $text[$i]);
$text[$i] = trim($text[$i]);
if ( empty($text[$i]) || $text[$i] == " " || $text[$i] == "" || $text[$i] == " /n" || $text[$i] == "/n")
{
unset($text[$i]);
}
}
print_r($text);
?>
Code: Alles auswählen
Array
(
[36] => </tr>
[37] => <tr>
[38] => <td width="9%"> <div align="left"></div></td>
[39] => <td width="82%"> <div align="center">
[40] => <p><strong>titel</strong></p>
[41] => </div></td>
[42] => <td width="9%"> </td>
[43] => </tr>
[44] => <tr>
[45] => <td height="30"> </td>
[46] => <td height="30"> </td>
[47] => <td height="30"> </td>
[48] => </tr>
[49] => <tr>
[50] => <td height="30"> </td>
[51] => <td><div align="center">
[52] => <p>textzeile
[53] => textzeile
[54] => textzeile
[55] => textzeile
[56] => textzeile
[57] => textzeile
[58] => textzeile</p>
[59] => </div></td>
[60] => <td height="30"> </td>
[61] => </tr>
[62] => <tr>
[63] => <td width="9%" height="30"> </td>
[64] => <td width="82%" height="30"> <div align="right"><font face="Arial, Helvetica, sans-serif"><a href="lexikon.htm">zurück</a></font></div></td>
[65] => <td width="9%" height="30"> </td>
[66] => </tr>
[67] => </table>
[68] => </div>
[69] => </body>
[70] => </html>
)
Code: Alles auswählen
<td colspan="3"> </td>
Code: Alles auswählen
<?php
$datei = "dateiname.htm";
$text = file($datei);
$textzeilen = count($text);
for ($i = 0; $i < $textzeilen; $i++)
{
$text[$i] = preg_replace("/\<(.*?)\>/si", "", $text[$i]);
$text[$i] = str_replace(" ", "", $text[$i]);
$text[$i] = str_replace("<!--", "", $text[$i]);
$text[$i] = str_replace("var thispagename = self.location.href.substring(self.location.href.lastIndexOf('/')+1,self.location.href.length);", "", $text[$i]);
$text[$i] = str_replace("if(!parent.mainFrame)", "", $text[$i]);
$text[$i] = str_replace("{", "", $text[$i]);
$text[$i] = str_replace("}", "", $text[$i]);
$text[$i] = str_replace('window.location.href="index.html?"+thispagename;', "", $text[$i]);
$text[$i] = str_replace("//-->", "", $text[$i]);
$text[$i] = trim($text[$i]);
if ( empty($text[$i]) )
{
unset($text[$i]);
}
}
$text = array_values($text);
print_r($text);
?>
Code: Alles auswählen
<?php
$aktuell = getcwd();
$verzeichnis = opendir($aktuell);
while ($eintrag = readdir())
{
if (is_file($eintrag) && strrchr($eintrag, ".") == '.htm' )
{
$text = file($eintrag);
$textzeilen = count($text);
for ($i = 0; $i < $textzeilen; $i++)
{
$text[$i] = str_replace(">zurück<", "><", $text[$i]); // Diverse Filter für Tags, Zeilen und Wörter, die wir nicht gebrauchen können.
$text[$i] = preg_replace("/\<(.*?)\>/si", "", $text[$i]);
$text[$i] = str_replace(" ", "", $text[$i]);
$text[$i] = str_replace("<!--", "", $text[$i]);
$text[$i] = str_replace("var thispagename = self.location.href.substring(self.location.href.lastIndexOf('/')+1,self.location.href.length);", "", $text[$i]);
$text[$i] = str_replace("if(!parent.mainFrame)", "", $text[$i]);
$text[$i] = str_replace("{", "", $text[$i]);
$text[$i] = str_replace("}", "", $text[$i]);
$text[$i] = str_replace('window.location.href="index.html?"+thispagename;', "", $text[$i]);
$text[$i] = str_replace("//-->", "", $text[$i]);
$text[$i] = trim($text[$i]);
if ( empty($text[$i]) )
{
unset($text[$i]);
}
}
$text = array_values($text);
$titel = addslashes($text[0]);
$beschreibung = addslashes(trim(str_replace($titel, '', implode(" ", $text))));
if ( !empty($titel) && !empty($beschreibung) && strpos($titel, 'Adobe Web-Fotogalerie') === false ) // Hier werden die Dateien gefiltert, die nicht zum Lexikon hinzugefügt werden sollen. Am besten vor dem SQL erst alle Titel und Beschreibungen per Echo ausgeben
{
$sql = "INSERT INTO ". LEXIKON ." (titel,text) VALUES ('$titel','$beschreibung')";
if ( !mysql_query($sql) )
{
die("Message: Could not update lexikon information <br> at File: " . __FILE__ . " on line: " . __LINE__);
}
}
}
}
closedir($verzeichnis);
?>
Code: Alles auswählen
$titel = addslashes($text[0]);
$beschreibung = addslashes(trim(str_replace($titel, '', implode(" ", $text))));
if ( !empty($titel) && !empty($beschreibung) && strpos($titel, 'Adobe Web-Fotogalerie') === false ) // Hier werden die Dateien gefiltert, die nicht zum Lexikon hinzugefügt werden sollen. Am besten vor dem SQL erst alle Titel und Beschreibungen per Echo ausgeben
{
$sql = "INSERT INTO ". LEXIKON ." (titel,text) VALUES ('$titel','$beschreibung')";
if ( !mysql_query($sql) )
{
die("Message: Could not update lexikon information <br> at File: " . __FILE__ . " on line: " . __LINE__);
}
}
Code: Alles auswählen
print_r($text);