I need to get all {SOME_STRING} from a paragraph as an array. For example :
Bla bla bla some {first} some string bla {second} bla bla .....
I have to get them like this array :
$array[0] 开发者_如何转开发= "first";
$array[1] = "second";
This is the REGEX pattern for {SOME_STRING} : \{.+}
Which method can i use ?
$str = "Bla bla bla some {first} some 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"
}
精彩评论