Jump to content

Recommended Posts

Ok, so here it goes:

 

I have a variable:

 

$var = ":12:3{this is a test}:5:8{this is another test}:"

 

Everything between : : is a separate value, which I can easily extract in an array:

 

$value=explode(":",$var);

 

I then get:

 

$value[0]=12

$value[1]=3{this is a test}

$value[2]=5

$value[3]=8{this is another test}

 

RE values like $value[1] and $value[3] with brackets, I would like to extract the number before the bracket '{' in one variable, and then all the text between the brackets {} in another variable, which should result in something like this:

 

$key=3

$keytext=this is a test

 

How can I achieve this?

 

I am sure this one will be dead simple for PHP experts, so many thanks in advance!

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.