I'm trying to grab all text between the HTML Tags (if there), and put a function on it .. i mean.. my code now is
$code = preg_replace_callback('/(\(\s*\')\s*(.*?)\s*(\')/',
function($matches) {
return strtolower($matches);
}, $code);
now what i want is :
If there is a HTML tags === Return HTML tags + strtolower(for the text between the tags).
If there isn't a HTML tags === Return strtolower(all the t开发者_运维技巧ext)
example : if we have :
('TEST HERE this is a TEXT')
return
('test here this is a text')
but if with HTML tags like
<DIV CLASS='tesT'>This IS A TEXT</DIV><Div class='Test1'>THIS is another TEXT</DIV>
return
<DIV CLASS='tesT'>this is a text</DIV><Div class='Test1'>this is another text</DIV>
$str = preg_replace_callback( '/(<.+?>)*(.*?)/s', 'replace', $str );
function replace( $matches ) {
return $matches[1].strtolower( $matches[2] );
}
精彩评论