سؤال

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