0

i have a string that looks like this:

$query = '(((306352743) and (306354310 OR 306354381 OR 306354379 OR 306354383 OR 306354372 OR 306354371 OR 306354378 OR 306354384 OR 306354373 OR 306354375 OR 306354376 OR 306354377 OR 306354382 OR 306354380 OR 306354374)) and ((306348630 OR 306347920) and (306348630)))';

and i want to parse it in to some kind of array that i can easly loop through. any sugestions?

4
  • 2
    What output do you expect for this input? Commented Dec 20, 2010 at 13:56
  • Do you want to follow the logic (i.e.: the ANDs or ORs), or simply parse out the values, or ? Commented Dec 20, 2010 at 13:59
  • @sjngm Thanks for the proclamation! Commented Dec 20, 2010 at 14:02
  • woeps diddent even know there was a accept ratio. i will accept the answers in the future Commented Dec 20, 2010 at 15:25

1 Answer 1

1

What I would try, is using string functions to replace all parens with square brackets, then wrap each number or word in quotes, then inserting a comma between each, until you have a string that you can use with json_decode() to parse into an array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.