Answer the question
In order to leave comments, you need to log in
How to select options in json_decode in php?
json_decode returns an array with data when I make a selection - the variable is empty:
<?php
header('Content-Type: text/html; charset= utf-8');
$token = 'МОЙ ТОКЕН';
$api = 'https://api.telegram.org/bot' . $token;
$output = json_decode(file_get_contents($api . '/getUpdates'), TRUE);
//var_dump($output);
$message = $output['message']['text'];
echo 'Текст' . $message;
?>
Answer the question
In order to leave comments, you need to log in
What does var_dump($output); show?
The variable is empty because there are no such keys in the array and will not be, because getUpdates returns something else.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question