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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -