I have a string such as:
#sometag-{serialized-data-here}
And I want to match this pattern, but use everything inside the curly braces (so I can unserialize it later). How can I match this text pattern with preg_match()?
So far I have:
preg_match('~{[^{}]*}~', $text, $match);
but this just matches the contents of the braces if in $text without the hash tag.
EDIT: Here is the logic of what im trying to accomplish:
$user_post = "Here is my cool post that contains some media.";
$media = array("mediatype" => "sometype", "id" => "ebJ2brErERQ", "title" => "Some cool video", "description" => "Some cool description");
$user_post .= "#sometag-" . serialize($media);
Later, when I fetch $user_post from the database, I want to match the text, strip it out and display the media.
I'll have something like this:
Here is my cool post that contains some media.#sometag-a:4:{s:9:"mediatype";s:8:"sometype";s:2:"id";s:11:"ebJ2brErERQ";s:5:"title";s:15:"Some cool video";s:11:"description";s:21:"Some cool description";}