Menu
My experience with objects is so limited that I probably don’t use the right words for things, but I’m learning.
I get data from an API as XML and use simplexml_load_string to parse it into an object.
I have elements like this:
[CODE]$results->Detail->Price1
$results->Detail->Price2
$results->Detail->Price3
$results->Detail->Price4
$results->Detail->Price5
How do I work with these sequentially?
Similar to how I’d do this:
[CODE]
$var1=”foo”;
$var2=”bar”;
//…
$i=1;
while ($i < 3){ //or <= number of vars
$nowvar=’var’.$i;
echo ($$nowvar.”n”);
$i++;
}
//foo
//bar