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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.