1

HTMLタグ間のすべてのテキストを取得しようとしています(存在する場合)、それに関数を配置しようとしています..つまり..私のコードは今

$code = preg_replace_callback('/(\(\s*\')\s*(.*?)\s*(\')/',
        function($matches) {
            return strtolower($matches);
        }, $code);

今私が欲しいのは:

  1. HTMLタグがある場合 === HTMLタグを返す + strtolower(タグ間のテキスト)。

  2. HTML タグがない場合 === strtolower(すべてのテキスト) を返す


例: ある場合:

('TEST HERE this is a TEXT')

戻る

('test here this is a text')

しかし、次のようなHTMLタグがある場合

<DIV CLASS='tesT'>This IS A TEXT</DIV><Div class='Test1'>THIS is another TEXT</DIV>

戻る

<DIV CLASS='tesT'>this is a text</DIV><Div class='Test1'>this is another text</DIV>
4

1 に答える 1

0
$str = preg_replace_callback( '/(<.+?>)*(.*?)/s', 'replace', $str );

function replace( $matches ) {
    return $matches[1].strtolower( $matches[2] );
}
于 2011-08-04T09:45:07.367 に答える