P
P
pw0ned2017-02-06 14:43:24
PHP
pw0ned, 2017-02-06 14:43:24

How to take only one value from the json response and return it to the page?

I have this code:

<?php

$p_url = $_POST['p_url'];
$url = 'https://site.ru/?url='.$p_url.'';

$result = file_get_contents($url);
echo $result;

?>

I turn to the Api of the page, in response to the main page, a lot of values ​​\u200b\u200bcome, but I only need to take this:
"media_id": "это нужно выводить",
How to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@smple, 2017-02-06
@pw0ned

Like this:

<?php

$p_url = $_POST['p_url'];
$url = 'https://site.ru/?url='.$p_url.'';

$result = file_get_contents($url);
echo json_decode($result, true)['media_id'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question