I’m simply iterating through nodes and adding the name of the node to an array but it is creating it as multidimensional array instead of one dimensional.
$arrayname[] = attribute[‘name’];
How do I get this to build as a one dimensional array? I need it this way as I’m checking to see if a value exists before adding it using in_array.
Right now I get
[0] SimpleXMLElement Object
(
[0] => bob
)
SimpleXMLElement
s have to be cast to string type to use as a string. Change your code to this (assuming your attributes array is $attribute
):
$arrayname[] = (string)$attribute[‘name’];