Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

Grabbing PHP variable

Having trouble grabbing the URL field from this string in php:

object(SimpleXMLElement)#11 (1) { ["@attributes"]=> array(2) { ["url"]=> string(46) "http://pbs.twimg.com/media/Cr2xto1UkAA56xV.jpg" ["type"]=> string(10) "image/jpeg" } }

Open in new window


Tried

$e->@attributes->url
$e['@attributes']['url']

Neither are working for me
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brad Brett
This will work:

$e->attributes()->url;

Open in new window

See line 75 in the prior code snippet.  It might  be necessary to cast the variable as a string, depending on what you want to do with the URL.
@N R:
I encourage you to read more about using SimpleXMLElement class:
http://php.net/manual/en/class.simplexmlelement.php