pleini
31.08.2007, 12:13
Hallo!
Ich möchte mit PHP eine Funktion bauen, die aus einem HTML-Code
z.B.
<html>
<body>
<table border="0">
<tr><td><img src="bild.gif" alt="bild" width="300"></td></tr></table>
<img src="test.jpg" alt="test" height="400" />
</body>
</html>
alle gesuchten Tags (z.B. img) samt Attributen als Array auslesen.
Also beispielsweise search("img") liefert ein
Array {
[0]["full_tag"] => "<img src="bild.gif" alt="bild" width="300">"
["src"] => "bild.gif"
["alt"] => "bild"
["width"] => 300
[1]["full_tag"] => "<img src="test.jpg" alt="test" height="400" />"
["src"] => "test.jpg"
["alt"] => "test"
["height"] => 400
}
, wobei search("table") entsprechend dieses
Array {
[0]["full_tag"] => "<table border="0">"
["border"] => 0
}
liefert.
Das Ganze sollte auch mit XHTML funktionieren.
Ich habe jetzt schon recht lange gegoogelt und im Forum gesucht, aber leider nichts gefunden.
Habt ihr ne Idee?
Gruß pleini!
Ich möchte mit PHP eine Funktion bauen, die aus einem HTML-Code
z.B.
<html>
<body>
<table border="0">
<tr><td><img src="bild.gif" alt="bild" width="300"></td></tr></table>
<img src="test.jpg" alt="test" height="400" />
</body>
</html>
alle gesuchten Tags (z.B. img) samt Attributen als Array auslesen.
Also beispielsweise search("img") liefert ein
Array {
[0]["full_tag"] => "<img src="bild.gif" alt="bild" width="300">"
["src"] => "bild.gif"
["alt"] => "bild"
["width"] => 300
[1]["full_tag"] => "<img src="test.jpg" alt="test" height="400" />"
["src"] => "test.jpg"
["alt"] => "test"
["height"] => 400
}
, wobei search("table") entsprechend dieses
Array {
[0]["full_tag"] => "<table border="0">"
["border"] => 0
}
liefert.
Das Ganze sollte auch mit XHTML funktionieren.
Ich habe jetzt schon recht lange gegoogelt und im Forum gesucht, aber leider nichts gefunden.
Habt ihr ne Idee?
Gruß pleini!