Skip to content

Instantly share code, notes, and snippets.

@Xatenev
Created April 23, 2015 15:36
Show Gist options
  • Save Xatenev/229baf615673988f9914 to your computer and use it in GitHub Desktop.
Save Xatenev/229baf615673988f9914 to your computer and use it in GitHub Desktop.
Array 1 holds keys which are allowed in Array 2.
foreach($articles->category->devices as $device) { // Iterate through all objects
foreach ($device as $key => $value) { // Iterate through all properties
if (!in_array($key, $allowedFields)) { // Find property in pre-defined array with the properties which are allowed for this object
unset($device->$key); // unset the properties which doesn't match the array
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment