Newbie PHP: Insert a variable for echoing -
Newbie PHP: Insert a variable for echoing -
i'd able echo $domain this
$domain = $response['results']['$myvar']['shorturl'];
i've tried curly braces , various other ways of formatting $myvar syntax wrong.
help 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 "domain.com" element fine when this:
var_dump($response['results'][$myvar]);
it returns null ! must why $domain = $response['results'][$myvar]['shorturl']; fails too. odd !
--edit 2 --
var_dump($myvar); gives:
string(118) "http://www.domain.com"
try this:
$domain = $response['results'][$myvar]['shorturl']; echo $domain; are sure it's stored in 3 dimentional array that? because looks needless complication.
php variables
Comments
Post a Comment