Struggling with array and foreach loop

You can get an array with just the numbers by using

array_values($your_array);

It will return an array with just the numbers. Is this what you need, or a string with a comma separated list of IDs?

If that’s the case, use this:

implode(",",array_values($your_array));

Hope this helps.