php - Get text between two tags -
how can value following tags:
{desc=1} description {/desc}
the number in {desc=1}
changing. want value well.
updated:
also possible more desc
in string, example
{desc=1} description {/desc} {desc=2} other description {/desc} ...
this capture want.
$data = <<<eot {desc=1} description {/desc} {desc=2} other description {/desc} eot; preg_match_all('#{desc=(\d+)}(.*?){/desc}#s', $data, $matches); var_dump($matches);
output:
array(3) { [0]=> array(2) { [0]=> string(44) "{desc=1} description {/desc}" [1]=> string(40) "{desc=2} other description {/desc}" } [1]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "2" } [2]=> array(2) { [0]=> string(29) " description " [1]=> string(25) " other description " } }
Comments
Post a Comment