How to implode array indexes?
Asked Answered
V

1

5

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

Voluble answered 18/9, 2012 at 22:30 Comment(0)
T
16

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).

Trichromat answered 18/9, 2012 at 22:31 Comment(1)
It's worth noting that this will work for either auto assigned indicies, or for those you assign yourself with square bracket notation.Trumaine

© 2022 - 2024 — McMap. All rights reserved.