1

I have a function that outputs an array with 2 objects(?):
Array ( [de] => 166 [it] => 167 )
Where [xx] is de language code and the number is the pageID.

I'm having a meltdown in my brain as I cannot figure out anymore how to use the pageID's in a foreach loop.

EDIT: See here as the reference of what I'm doing.
The filter outputs the above and I only need to two numbers (which are page-ids), but I cannot figure out how to get them out.

Can someone lend me a helping hand to show me how to do this again. I know it should be something relatively simple, but I'm drawing blanks :(

Thanks in advance!

3
  • foreach ($array as $lan => $pageID){} ?
    – Sisir
    Jan 29, 2016 at 8:32
  • I probably should have made it more clear, because the pageID is not mentioned as such, please have a look here: wpml.org/wpml-hook/wpml_post_duplicates
    – user2015
    Jan 29, 2016 at 8:37
  • @Sisir I edited my question to hopefully make it more clear. Thx
    – user2015
    Jan 29, 2016 at 8:46

1 Answer 1

0

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.

0

Your Answer

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