php - Extract keyword that Word Pattern -


i have string.

hi {$user_name} test msg {$user1,$user2,$user3} 

i want extract {$word} string. have tried use str_replace not working.

short solution preg_mach_all function:

$str = 'hi {$user_name} test msg {$user1,$user2,$user3}'; preg_match_all('/\s*(\{\$[^\{\}]+\})+\s*/iue', $str, $matches);  echo "<pre>"; var_dump($matches[1]);  // output: array(2) {   [0]=>   string(12) "{$user_name}"   [1]=>   string(22) "{$user1,$user2,$user3}" } 

http://php.net/manual/ru/function.preg-match-all.php


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

post - imageshack API cURL -