Somebody's building a template system, but doesn't kno' how to search with regex.
$str = '
Så vil jeg gerne hive det tekst ud, som er mellem <!--start test--> These few lines of code we have given you will allow anyone to upload data to your server. Because of this, we recommend that you do not have such a simple file uploader available to the general public. Otherwise, you might find <b>that</b> your server is filled with junk or that your servers security has been compromised. <!--slut test--> og lagt i en variabel.
Så vil jeg gerne hive det tekst ud, som er mellem <!--start tesat--> of code we have given you will allow anyone to upload data to your server. Because of this, we recommend that you do not have such a simple file uploader available to the general public. Otherwise, you might find <b>that</b> your server is filled with junk or that your servers security has been compromised. <!--slut tesat--> og lagt i en variabel.
Så vil jeg gerne hive det tekst ud, som er mellem <!--start--> of code we have given you will allow anyone to upload data to your server. Because of this, we recommend that you do not have such a simple file uploader available to the general public. Otherwise, you might find <b>that</b> your server is filled with junk or that your servers security has been compromised. <!--slut--> og lagt i en variabel.
';
preg_match_all('/<!--\\s*start(\\s*[^-]*)-->(.*)<!--\\s*slut\\\\1-->/',$str,$matches);
foreach($matches[1] as $i => $k){
if(!empty($k)){
$result[trim($k)] = $matches[2][$i];
} else {
$result[] = $matches[2][$i];
}
}
print '<pre>'.htmlentities(print_r($result,true));
Indlæg senest redigeret d. 24.04.2008 22:17 af Bruger #10216