- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
//with ^
$str = " {user:fname} and the last name = {user:lname}";
preg_match_all("/^\{(\w):(\w)\}/", $str, $matches);
print_r($matches);
//without ^
preg_match_all("/\{(\w):(\w)\}/", $str, $matches2);
print_r($matches2);