Wednesday, 15 January 2014

php - Warning: preg_match(): Unknown modifier 't' -



php - Warning: preg_match(): Unknown modifier 't' -

help me plese :

function gettextbetweentags($string, $tagname) { $pattern = "/<$tagname>(.*?)<\/$tagname>/"; preg_match($pattern, $string, $matches); homecoming $matches[1]; }

i got : warning: preg_match(): unknown modifier 't'

also, have try:

$pattern = "~<$tagname>(.*?)<\/$tagname>~";

in case, have :

warning: preg_match(): compilation failed: range out of order in character class @ offset 146 in

sure, have seek variants

$pattern = "/<".$tagname.">(.*?)<\/".$tagname.">/";

any ideas ? )

you need alter places of parameters in gettextbetweentags call. 'abc' name of tag, not string search into, right?

$html = "<html><body><abc>hello</abc></body></html>"; function gettextbetweentags( $string, $tagname ) { preg_match( "/\<{$tagname}\>(.*)\<\/{$tagname}\>/", $string, $matches ); homecoming $matches[1]; } var_dump( gettextbetweentags( $html, 'abc' ) );

php preg-match

No comments:

Post a Comment