Reputation: 2700
$str='<html>...<header>...</header>...</html>';
//$str='<HTML>...<HEADER>...</HEADER>...</HTML>';
$header = explode("<header>", $str, 2);
echo $header[1];
I have many html code, I want explode header
tag, but some uppercase
and some are lowercase
, cause the $str
is very huge, I do not want use str_replace()
change them all to uppercase
or lowercase
, is there any easy way to explode header
tag for 2 part from a $str
? Thanks.
Upvotes: 1
Views: 1821
Reputation: 13
To use explode and uppercase, you may opt for the following solution:
$pieces = explode(" ", strtoupper($pizza));
Hope this would work for you.
Thanks
Upvotes: 1
Reputation: 33501
There is a way - preg_split() function!
Didn't test the regex, but i think this is what you're looking for:
$header = preg_split("/<header>/i", $str);
Upvotes: 4