0

I have a PHP array and what I am trying to do is use that in my MySQL query to select only the ones that are in the array.

I have this:

SELECT * FROM table IN ('.implode(',', $array).')

I guess what needs to happen is I need quotes around each array item for this to work. Right now it just has one, two, three, four where it should be "one", "two", "three", "four"

How could I do that? Or is there another way to do what I am looking for?

Thanks!

2

1 Answer 1

4

This would do it,

"'" . implode("','", $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.