Hallo Gunnar™
Man könnte die Spielchen mit den Stringfunktionen durchaus noch weiter treiben, […]
Und es spricht auch eigentlich nichts dagegen, da das title-Element über kein Attribut verfügt, welches das Zeichen „>“ enthalten könnte:
<?php
$str_html = '<html><head><title>Foo</title></head><body><p>Bar</p></body>'; // Simples HTML-Dokument
$int_start = stripos($str_html, '<title'); // Position des Anfangstags
if ($int_start !== false) {
$int_start = strpos($str_html, '>', $int_start); // Terminator des Anfangstags
$int_start += 1; // strlen('>') == 1
$int_end = strpos($str_html, '</', $int_start); // Position des title-Endtags
echo substr($str_html, $int_start, $int_end - $int_start); // „Foo“
}
?>
Dank stripos ist nun auch egal, ob Groß- oder Kleinschreibung.
Ich habe meine Zweifel daran, dass eine Trennung von Anfangszeichen und Name des Elementes erlaubt ist. Zumindest kann ich in der HTML-Spezifikation dazu nichts finden.
Einen schönen Sonntag noch.
Gruß, Ashura
--
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“
[HTML Design Constraints: Logical Markup]
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“
[HTML Design Constraints: Logical Markup]