How can I best trim the following text outside the braces:
$myString = "10:0{ 'name':'John', 'age':30, 'car':null }24:0";
The text outside of the braces 10:0
and 24:0
may vary.
How can I best trim the following text outside the braces:
$myString = "10:0{ 'name':'John', 'age':30, 'car':null }24:0";
The text outside of the braces 10:0
and 24:0
may vary.
Just grab what's inside the braces:
preg_match('/{[^}]+}/', $myString, $match);
echo $match[0];