Find values between curly brackets using preg php

I have a string

{Col 1}+{Col 2}

I would like to get:
array (
{Col 1}
{Col 2}
)

nbcitAsked:
Who is Participating?
 
ddrudikConnect With a Mentor Commented:

<?php
$sourcestring='{Col 1}+{Col 2}';
preg_match_all('/\{[^}]*\}/',$sourcestring,$matches);
$matches=$matches[0];
?>

Open in new window

0
 
nbcitAuthor Commented:
Fantastic!
0
 
ddrudikCommented:
Thanks for the question and the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.