3

I'm performing a for loop to iterate through MLS listings. I'm able to get every bit of information I need but I can't seem to figure out how to extract the URL from the array I get.

Here's the array I get from my for loop:

PHRETS\Models\Object Object

(

[content_type:protected] => text/xml
[content_id:protected] => 9577056
[object_id:protected] => 1
[mime_version:protected] => 
[location:protected] => http://cdnparap100.paragonrels.com/ParagonImages/Property/P10/CAT/9577056/0/0/0/42ab28468ab0dfc6fd83dfb39e5dfff7/3/55ec2da6d4a32437d345d0992fae1851/9577056.JPG
[content_description:protected] => 
[content_sub_description:protected] => 
[content:protected] => 


[preferred:protected] => 
[error:protected] => PHRETS\Models\RETSError Object
    (
        [code:protected] => 0
        [message:protected] => 
    )

)

The following is the code I'm using to get that output. I'm just wondering if there's a way to do a trim or something to extract the URL so I can store it.

for ($i = 0; $i <= count($listID); $i++) {

$photo = $rets->GetObject('Property', 'Photo', $mls, '*', 1);

foreach ($photo as $image) {
    echo "<pre>";
    print_r($image);
    echo "<br>";
    echo "</pre>";
}
}
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
TomG103
  • 311
  • 2
  • 26
  • Just a slight correction: The type returned is an object, of the class "Object" (terrible naming, btw), not an array. The first line `PHRETS\Models\Object Object` specifies the namespace (`PHRETS\Models\ `), the name of the class (`Object`) and the variable type (second `Object`). Another indicator are the visibility keywords after the property names. ;) – ChristianF Nov 18 '16 at 10:28

1 Answers1

4

You mean like

foreach ($photo as $image) {
    echo 'Location: ', $image->getLocation(), '<br>';
}

?

See https://github.com/troydavisson/PHRETS/blob/master/README.md#downloading-media-photos-images-documents-etc

The method is detailed here ~ https://github.com/troydavisson/PHRETS/blob/master/src/Models/Object.php#L109

Phil
  • 157,677
  • 23
  • 242
  • 245
  • It says I have to wait 23 hours to award the bounty....I will be back tomorrow night and give you this bounty!!! – TomG103 Nov 15 '16 at 02:54