Reputation: 5172
I'm reading an XML with SimpleXML. A node is made in this mode:
$docType = $doc->DocumentType;
If i do
print_r($docType);
I'm getting:
SimpleXMLElement Object ( [0] => B )
And this is right. Now, i need to "simply" put the "B" into a variable, to obtain this goal:
$daneadoc['B'] = 'Scontrino / Vendita al banco';
$daneadoc['I'] = 'Fattura';
(I have an array for several value for "daneadoc").
Obviously, if I put
echo $daneadoc[$docType];
It's Illegal offset type
But if i write
$documento = $docType[0];
echo $daneadoc[$documento];
My server says same (illegal type). Same if I write
echo $daneadoc[$docType[0]];
My question is... How i can convert obkect in a single variable to put in the array $daneadoc?
Thank you very much!
Upvotes: 0
Views: 58
Reputation: 7685
I am not sure if I understood your question, but try:
$docTypeString = (string) $docType;
$daneadoc[$docTypeString] = 'Scontrino / Vendita al banco';
Upvotes: 1