php - Extracting delimited strings from a paragraph -


i need {some_string} paragraph array. example :

bla bla bla {first} string bla {second} bla bla ..... 

i have them array :

$array[0] = "first"; $array[1] = "second"; 

this regex pattern {some_string} : \{.+}

which method can use ?

$str = "bla bla bla {first} string bla {second} bla bla ....."; $matches = array(); preg_match_all("/\{(.+?)\}/", $str, $matches); $array = $matches[1];  var_dump($array); 

output

array(2) {   [0]=>   string(5) "first"   [1]=>   string(6) "second" } 

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 -