How To Get Content From Array Code

i have script json to aray like this

array (
  'status_code' => 200,
  'status_txt' => 'OK',
  'data' => 
  array (
    'url' => 'http://bit*ly/2jc5mvr',
    'hash' => '2jc5mvr',
    'global_hash' => 'CuJU',
    'long_url' => 'http://github.com/',
    'new_hash' => 1,
  ),
)

how to get short url result from that's array ? i have try this code

$json['url']

But, Not Work.

Upvotes: 1

Views: 33

Answers (1)

Ethan
Ethan

Reputation: 4375

Just try:

$json['data']['url']

You're trying to get 'url' from the top-level array, but you need to get it from the sub-level array ('data').

Upvotes: 1

Related Questions