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!

  • foreach ($array as $lan => $pageID){} ? – Sisir Jan 29 '16 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 – Pieter Jan 29 '16 at 8:37
  • @Sisir I edited my question to hopefully make it more clear. Thx – Pieter Jan 29 '16 at 8:46

You can get an array with just the numbers by using


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:


Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.