6

Is it possible to implode array's indexes? A function is returning me an array and what I need are the indexes of that array so I want to implode only inexes with comma or any other character for my db work

1 Answer 1

17

You mean something like this...

implode(',', array_keys($some_arr));

... right? ) Here's documentation for array_keys; in short, when called with a single argument (an array), this function just returns all its keys (as array).

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

1 Comment

It's worth noting that this will work for either auto assigned indicies, or for those you assign yourself with square bracket notation.

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.