문제

How would I delete all code or text before the <html> tag with a php code?

Asking because with OpenX no precaution of any kind seems to work, and injections keep turning up, but all before the <html> tag.

I tried this: $fullcode = strstr($fullcode, ''); to remove anything before <html>. (And more that didn't work.)

Hope someone can help me.

도움이 되었습니까?

해결책

You can use a regexp with positive lookahead:

<?php
$html = "text before html<html>text after html";
$html = preg_replace('/^.*(?=<html>)/i', '', $html);
print $html;

Prints:

<html>text after html
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top