Answer the question
In order to leave comments, you need to log in
How to change response to JSON value in PHP array?
I have an answer for the name value (different names) and the status value receives the answer 1 or 2, if the answer 1 is online, 2 offline how to display the word instead of the number 1, what should be added:
<?php
$jsonData = file_get_contents ("http ://");
$json = json_decode($jsonData, true);
echo '';
$output="";
foreach($json['results'] as $results)
{
$output.="".$results['name']."
";
$output.="".$results['status']."
";
$output.="
";
}
echo $output;
?>
Answer the question
In order to leave comments, you need to log in
$output .= $results['status'] == 2 ? "offline" : "online";
$output .= PHP_EOL;
$output.="".$results['status']."
";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question