Esempio:
<html>
<prova>
<h1>ciao</h1>
<h2>ciao</h2>
</prova>
<html>
Mi servirebbe un codice che praticamente mi dica:
-h1 e h2 sono nello stesso div che si chiama prova
Qualche idea?
Esempio:
<html>
<prova>
<h1>ciao</h1>
<h2>ciao</h2>
</prova>
<html>
Mi servirebbe un codice che praticamente mi dica:
-h1 e h2 sono nello stesso div che si chiama prova
Qualche idea?
aspetta qualcuno che ti dia la regex adatta, è molto banale, ma io non sono stato ferrato![]()
Prova questo. Assicuramente puo' essere migliorato ma è tardi (o presto).
Codice PHP:
<?php
$text = '<html><prova><h1>ciao</h1><h2>ciao</h2></prova><html>';
$pattern1 = "#<prova>(.*)<h1>(.*)<\/h1>(.*)<h2>(.*)<\/h2>(.*)</prova>#i";
$pattern2 = "#<prova>(.*)<h2>(.*)<\/h2>(.*)<h1>(.*)<\/h1>(.*)</prova>#i";
if (preg_match($pattern1,$text)) {
print "ok";
} else {
if (preg_match($pattern2,$text)) {
print "ok";
} else {
print "ko";
}
}
print "<hr/>";
$text = '<html><prova><h1>ciao</h1></prova><h2>ciao</h2><html>';
if (preg_match($pattern1,$text)) {
print "ok";
} else {
if (preg_match($pattern2,$text)) {
print "ok";
} else {
print "ko";
}
}
print "<hr/>";
$text = '<html><prova><h2>ciao</h2>KKLLLL<h1>ciao</h1></prova><html>';
if (preg_match($pattern1,$text)) {
print "ok";
} else {
if (preg_match($pattern2,$text)) {
print "ok";
} else {
print "ko";
}
}
?>
Ridatemi i miei 1000 posts persi !!!!
Non serve a nulla ottimizzare qualcosa che non funziona.
Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr
Ehi, attento che quel <prova> non è un div che si chiama prova
No
Ridatemi i miei 1000 posts persi !!!!
Non serve a nulla ottimizzare qualcosa che non funziona.
Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr