Skip to content

Instantly share code, notes, and snippets.

@NBoulfroy
Last active April 7, 2021 15:27
Show Gist options
  • Save NBoulfroy/f5270fc7ae0311a01ba5eecf95049ff9 to your computer and use it in GitHub Desktop.
Save NBoulfroy/f5270fc7ae0311a01ba5eecf95049ff9 to your computer and use it in GitHub Desktop.
[Get Attributes from SimpleXMLElement] Get Attributes from SimpleXMLElement in array #PHP
<?php
/**
* @param SimpleXMLElement $data
*
* @return array
*/
function getAttributes($data)
{
$attributes = [];
foreach ($data as $datum => $attribute) {
$attributes[] = $datum;
}
return $attributes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment