html - How to find the first <body .....> tag in a text using PHP? -
i not when using preg_match function
but trying use find first body tag.
the tag in of following formats
<body class="blah"> <body style="blah: blahblah;"> <body>
i able use preg_match() first , second example. but, not working on last example. simple <body>
not found.
here have done. $message
string trying parse
$foundbody = preg_match('/<body(.*)>/i',$message, $bodyf); if($foundbody != false){ $strpos = strpos($message, $bodyf[0]); echo $strpos .'<br><br>'; echo $bodyf[0] . '<br><br>'; echo strlen($bodyf[0]) . '<br><br>'; if($strpos !== false){ $message = substr($message, $strpos + strlen($bodyf[0]) ); } }
note: not prying parse html code. trying go here parse email. want return text begins after <body....>
tag end of string.
the following should print content after closing >
of <body>
tag 3 cases:
$i=strpos($message, "<body"); $i=strpos($message, ">", $i); echo substr($message, $i+1);
Comments
Post a Comment