tatarao Posted July 29, 2015 Share Posted July 29, 2015 Dear friends, I am new to PHP coding. I wrote a php script to display linux system hardware information in a browser. The script includes execution of linux commands and the result those command appended to one variable. To find usb information i wrote for loop within the script. When I am executing the script from linux terminal, it displays everything accurately. But the same script does not display the for loop result in case of browser. I attached my script with this post. Please find a solution and let me know what I have to do. Thanking you in advance. regards, Tata Rao, pihealth.php PHP developer, Mobodexter Quote Link to comment Share on other sites More sharing options...
iarp Posted July 29, 2015 Share Posted July 29, 2015 You've made this a lot harder on yourself. It looks like you're trying to format and print json by hand. I would recommend doing something along the lines of: $data_array = array( 'current_time' => '', 'uptime' => '', 'load_averages' => '', 'temperature' => '', 'memory' => array( 'ram' => array( 'total' => '', 'used' => '', 'free' => '', 'mem_percentage' => '', 'units' => 'Gigabytes' ), 'sd_card' => array( 'total' => '', 'used' => '', 'free' => '', 'mem_percentage' => '', 'units' => 'Gigabytes' ), ) ); echo json_encode($data_array); To set the RAM memory total $data_array['memory']['ram']['total'] = $where_ever_ram_total_comes_from; 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.