Cris
Cris

Reputation: 4044

How to extract the key & value from this particular string?

I have the following string:

address=test&address2=test2&[email protected]

How can I extract the keys (address, address2, email) and values ("test", "test2", "[email protected]")

Thank you!

Upvotes: 0

Views: 83

Answers (2)

tmjam
tmjam

Reputation: 1039

since this is just a string I would use explode() with delimiters as '&' and then '=', not a great idea but works

Upvotes: 0

piotrekkr
piotrekkr

Reputation: 3201

Use parse_str() http://pl.php.net/manual/en/function.parse-str.php

Upvotes: 5

Related Questions