herghost Posted March 17, 2010 Share Posted March 17, 2010 Hi all, This is the output of a json request to my server, which is currently stored in an array by single characters. { " r e s u l t " : { " s t a t u s " : 1 , " s t a t u s m s g " :null},"service":[ {"display_name":"ClamAV Daemon","installed":0,"enabled":1,"monitored":0,"name":"clamd"}, {"display_name":"cPanel Log and Bandwidth Processor","installed":1,"enabled":1,"monitored":0,"name":"cpanellogd"}, {"display_name":"cPanel DAV Daemon","installed":1,"enabled":1,"monitored":1,"name":"cpdavd"}, {"display_name":"cPanel Daemon","installed":1,"enabled":1,"monitored":1,"name":"cpsrvd"}, {"display_name":"Entropy Chat Server","installed":1,"enabled":0,"monitored":0,"name":"entropychat"}, {"display_name":"Exim Mail Server","installed":1,"enabled":1,"monitored":1,"name":"exim"}, {"display_name":"Ftp Server","installed":1,"enabled":1,"monitored":1,"name":"ftpd"}, {"display_name":"Apache Web Server","installed":1,"enabled":1,"monitored":1,"name":"httpd"}, {"display_name":"IMAP Server","installed":1,"enabled":1,"monitored":1,"name":"imap"}, {"display_name":"Interchange Server","installed":0,"enabled":0,"monitored":0,"name":"interchange"}, {"display_name":"IP Aliases","installed":1,"enabled":1,"monitored":0,"name":"ipaliases"}, {"display_name":"Melange Server","installed":1,"enabled":0,"monitored":0,"name":"melange"}, {"display_name":"MySQL Server","installed":1,"enabled":1,"monitored":1,"name":"mysql"}, {"display_name":"DNS Server","installed":1,"enabled":1,"monitored":1,"name":"named"}, {"display_name":"POP3 Server","installed":0,"enabled":1,"monitored":0,"name":"pop"}, {"display_name":"PostgresSQL Server","installed":1,"enabled":1,"monitored":0,"name":"postgresql"}, {"display_name":"TaskQueue Processor","installed":1,"enabled":1,"monitored":0,"name":"queueprocd"}, {"display_name":"rsyslogd","installed":1,"enabled":0,"monitored":0,"name":"rsyslogd"}, {"display_name":"SpamAssassin Server","installed":1,"enabled":1,"monitored":1,"name":"spamd"}, {"display_name":"SSH Daemon","installed":1,"enabled":1,"monitored":0,"name":"sshd"}, {"display_name":"System Logger Daemon","installed":0,"enabled":1,"monitored":0,"name":"syslogd"}, {"display_name":"TailWatch Daemon","installed":1,"enabled":1,"monitored":0,"name":"tailwatchd"}, {"display_name":"Tomcat Server","installed":0,"enabled":1,"monitored":0,"name":"tomcat"}]} Is there a way of putting one character on each line so I know what var() matches which character? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/195585-output-of-an-array/ Share on other sites More sharing options...
premiso Posted March 17, 2010 Share Posted March 17, 2010 Not really sure what you are asking, but depending on your PHP version, you can convert a JSON encoded array to a PHP array using the json_decode function. Which may make it easier to display / test data from that array. Quote Link to comment https://forums.phpfreaks.com/topic/195585-output-of-an-array/#findComment-1027694 Share on other sites More sharing options...
herghost Posted March 17, 2010 Author Share Posted March 17, 2010 basically I just want a line break after each character, dont know why I didnt think of this way of explaining it before! Quote Link to comment https://forums.phpfreaks.com/topic/195585-output-of-an-array/#findComment-1027711 Share on other sites More sharing options...
premiso Posted March 17, 2010 Share Posted March 17, 2010 str_split will put the string into an array by characters. If you want to add a line break after each character do an implode on the variable you set it to with "\n" being the glue portion. Quote Link to comment https://forums.phpfreaks.com/topic/195585-output-of-an-array/#findComment-1027713 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.