Answer the question
In order to leave comments, you need to log in
How to display json data on wordpress home page?
Hello. I have json with this content
"{'count':'13','updated_at':'2021-09-27 10:07:23'}"
<?php
$data = file_get_contents( 'https://site.com/json_config/count.json' );
if ( ! empty( $data ) ) {
$args = json_encode( $data );
foreach ($args as $el) {
print_r($el->count);
}
}
?>
Answer the question
In order to leave comments, you need to log in
Try like this:
<?php
header('Content-Type: text/plain; charset=UTF-8');
$data = file_get_contents('https://site.com/json_config/count.json');
if ($data !== false) {
$arr = json_decode($data, true);
echo "Из конфига получены следующие данные:\n";
echo print_r($arr, true);
}
else {
echo "Не удалось прочитать файл конфигурации!";
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question