Sunday, 15 February 2015

PHP Array - Return specific elements of array and display them on one line -


I am ready to go mad with this one. I can not seem to know how to print elements of an array and then put all the results on one line (with a specific output).

Here's my array data (this is a server 01 [server_id] => 4 [disk_mountpoint] => [[disk_data] => 1426395600 [code]> foreach statement:

  5 [disk_evice] => / dev / mapper / VolGroup00-LogVol00 [disk_capacity] => 15G [disk_committed] = & Gt; 5.3G) Array ([Hostname] => Server 01 [server_id] => 4 [disk_mountpoint] => Var [disk_datetime] => 1426395600 [disk_division] => Dev / mapper / VolGroup01-LogVol00 [disk_capacity] => 107G [disk_used] = & gt; 52G) array ([hostname] => server 01 [server_id] = & gt; 4 [disk_mountpoint] = & Gt; Opt [Disk_Data] => 1426395600 [DiskDevice] => / dev / mapper / VolGroup02- Logwoland [disk_package] = & gt; 156G [disk_US] => 127G)  < / Pre> 

Here is my foreach statement:

  foreach ($ archive_withport $ as item) {print_r ($ item);}  

I have spent a few hours trying to wrap my mind, along with a multi-dimension array, along with some other people looking at the questions on the stack overflow, but I do not take anything By the way, the array above is actually output from a MySQL query and it only returns a unique hostname , so where one object is similar The hostname is, it is correct (also with Server_id).

I also tried nested code foreach and he could not work well and I got confused again, so I did not want to post it here.

In fact, with the above data, I want to see the output:

  $ disk_mountpoint = $ disk_used  

It is being said that, the final output (if you had to pars me what I wrote), the final output would look like this:

  / = 5.3G / var = 52G / opt = 127G  

I think I am confused with things and want to know that someone can tell me in the right direction and can help me.

Thank you! Draw

Um .. Now:

  foreach ($ storage_report's $ Item in form) {echo $ item ['disk_mountpoint'] '='. $ Item ['disk_used']; }  

No comments:

Post a Comment