Jump to content

Help with Array Please


kphpm
Go to solution Solved by cyberRobot,

Recommended Posts

Hello Again.

 

Sorry i have to ask for help again.

 

Due to the Help in my other topic i managed a lot while working on my webinterface.

 

However now i have a issue again :(

 

ok here is the array

Array
(
    [0] => Array
        (
            [status] => 3
            [ip] => 178.21.114.239
            [maxsnapshot] => 5
            [hostname] => 
            [password] => 0
            [iso] => 14
            [tag] => 
            [imageid] => 0
            [traffic] => 500
            [paymenttypeid] => 0
            [ipv6] => 2a02:2308::216:3eff:fe91:1d1e
            [kernelid] => 0
            [bootorder] => 2
            [memory] => 1024
            [locationid] => 1
            [hwid] => 24
            [monitoring] => 0
            [vpsid] => 1201
            [sshkey] => 
            [product] => 
            [type] => 1
            [productid] => 32
        )

    [1] => Array
        (
            [status] => 3
            [ip] => 178.21.117.207
            [maxsnapshot] => 5
            [hostname] => 
            [password] => 0
            [iso] => 61
            [tag] => 
            [imageid] => 0
            [traffic] => 4000
            [paymenttypeid] => 0
            [ipv6] => 2a02:2308::216:3eff:fe0a:c826
            [kernelid] => 0
            [bootorder] => 0
            [memory] => 8192
            [locationid] => 1
            [hwid] => 195
            [monitoring] => 0
            [vpsid] => 1663
            [sshkey] => 
            [product] =>
            [type] => 1
            [productid] => 36
        )

    [2] => Array
        (
            [status] => 3
            [ip] => 141.105.120.61
            [maxsnapshot] => 5
            [hostname] => kevin
            [password] => 1
            [iso] => 0
            [tag] => Testserver
            [imageid] => 36
            [traffic] => 250
            [paymenttypeid] => 0
            [ipv6] => 2a02:2308::216:3eff:fe22:3f49
            [kernelid] => 27
            [bootorder] => 0
            [memory] => 512
            [locationid] => 1
            [hwid] => 52
            [monitoring] => 0
            [vpsid] => 1967
            [sshkey] => 
            [product] =>
            [type] => 2
            [productid] => 31
        )

)

Now i want to Display the results for example only for the vpsid 1967 , i know i can echo all results with a nested foreach loop but how to look for something inside the array in this case array 2 and display the rest of it?

Link to comment
Share on other sites

it worked i ended up using this :

$server = $directvps->go("get_vpslist");
$server = json_decode($server,true);
foreach($server as $result)
{
if ($result['vpsid'] == $vps)
{
printf("VPSID: %s<br>Monthly Traffic: %s",$result['vpsid'],$result['traffic']);
}
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.