I am a newbie in PHP. I am making a call to an http api using wget (the hosting site doesn't offer http_get). The call returns an xml set when do it manually. But it appears that my wget call is putting the response into an array.
I am unable to access the array and not sure where to go from here.
Below is my code. FYI -- The first 4 elements of the xml play_by_play object are: id, visitor, home, status.
<?php
exec('wget
http://api.sportsdatallc.org/mlb-t3/pbp/99a0f209-2c69-49a4-99f9-8aebdf55b6e9.xml?api_key=API_KEY';, $array);
//print_r(array_values($array));
echo $array["play_by_play"][0]->id;
?>
I have tried another approach and have confirmed that I am getting a response (count = 1). That is below. But I can't get to the content.
<?php
$myResult=exec('wget
http://api.sportsdatallc.org/mlb-t3/pbp/99a0f209-2c69-49a4-99f9-8aebdf55b6e9.xml?api_key=API_KEY';, $array);
print count($myResult);
print $myResult;
$arrElem="";
if (count($myResult) > 0)
{
for ($i=0;$i<count($myResult);$i++) {
$arrElem=ltrim(rtrim($myResult
));
echo $arrElem;
?>
Thanks,
Angie