Jump to content

Been trying now but can't figure this out


Ayon

Recommended Posts

I've been trying for a while now to get this regex to work, but i still haven't been able to get anything else than the curly brackets :( could anyone please help me out? :shrug:

 

$string = "test {id:5;name:Helbom}, test";
if (preg_match_all("/[\{(*.?)\}]/",$string,$matches))
{
print_r($matches);
}
$smarty->display('index.tpl');

 

Thanks in advance

Link to comment
Share on other sites

You dont need the square brackets, and to match everything between the curlies you need dot(anything) *(whatever follows) until the next delimiter. Also in your example string to only have one set of brackets so you dont need _all as that gives you a multi-array

 

preg_match("/\{.*\}/",$string,$matches)

 

HTH

Teamatomic

Link to comment
Share on other sites

I was abit quick here... it's still not working as i want to

 

i've got the following string {artist1} & {artist2} and i want to separate the to artists into an array so that i can link to each profile

 

but for now it stores the whole string as one

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.