fish man
fish man

Reputation: 2700

php explode uppercase lowercase

$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

Answers (2)

pawanjoshi5
pawanjoshi5

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

naivists
naivists

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

Related Questions