I’d like to be able to echo $domain from this
$domain = $response['results']['$MYVAR']['shortUrl'];
I’ve tried curly braces and various other ways of formatting $MYVAR but the syntax is wrong.
Help most welcome !
EDIT –> var_dump($response):
object(stdClass)#1 (4) {
["errorCode"]=> int(0)
["errorMessage"]=> string(0) ""
["results"]=> object(stdClass)#2 (1) {
["http://www.domain.com"]=> object(stdClass)#3 (5) {
["userHash"]=> string(6) "oSEMki"
["shortKeywordUrl"]=> string(0) ""
["hash"]=> string(6) "oms2ZB"
["shortCNAMEUrl"]=> string(20) "http://bit.ly/LALALA"
["shortUrl"]=> string(20) "http://bit.ly/LALALA"
}
}
["statusCode"]=> string(2) "OK"
}
I can see the “domain.com” element fine but when I do this:
var_dump($response[‘results’][$MYVAR]);
it returns NULL ! Which must be why $domain = $response[‘results’][$MYVAR][‘shortUrl’]; fails too. Odd !
–EDIT 2 —
var_dump($MYVAR); gives:
string(118) "http://www.domain.com"
Try this:
Are you sure it’s stored in a 3 dimentional array like that?
Because that looks like needless complication.