php SimpleXMLElement attributes variable

WeFeLLinLoVe

New Member
My XML file is fairly simple\[code\]<myXml> <item a="1" b="l" c="0"></item> <item a="0" b="l" c="0"></item> <item a="0" b="l" c="0"></item></myXml>\[/code\]In my php I want to check if either a, b or c attributes are =1, but I don't want to check all possibilities \[code\](if a == 1) {} if (b == 1) {} if (c == 1)\[/code\]as on every single page I need to check just one parameter: $paramso for example if my $param = "b"; then my php should check only if (b == 1)so my question ishow should i replace $a in "->attributes()->$a" with the variable name? ie: \[code\]if ($item->attributes()->**$param** == "1") {}\[/code\]as this code won't work...
 
Back
Top