[HELP] PHP Array help please!

3 posts Page 1 of 1
Contributors
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

[HELP] PHP Array help please!
Scottie1972
here is the array
Code: Select all
Array
(
    [Protocol] => 17
    [HostName] => Scottie's TFC Server
    [Map] => epicenter
    [ModDir] => tfc
    [ModDesc] => Team Fortress Classic
    [AppID] => 20
    [Players] => 6
    [MaxPlayers] => 16
    [Bots] => 6
    [Dedicated] => d
    [Os] => w
    [Password] => 1
    [Secure] => 1
    [Version] => 1.1.2.2
    [GamePort] => 27015
)
now what i need is help fetching each array "[Key]" by itself.
then i want to be able to display the [Key] => "value"

for example:
Code: Select all
<div>HostName: 
 <?php 
  echo ["Key"] => "value"; 
 ?>
</div>
does this makes since?
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: [HELP] PHP Array help please!
mandai
This code will declare an array with keys and then output each value and key:
Code: Select all
$arr = array(
"key1" => "value1",
"key2" => "value2"
);

while (list($key, $value) = each($arr))
{
 echo "$key, $value\r\n";
}
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

not sure if i mis-lead you or not mandai.
LINK: http://scottie1972.dyndns.org/_tfc/_test/xPaw/

the array is already built. I need to know how to access it to display some of the data.

What i am trying to make is this:
Image

this comes from GameTracker.com and I want to NOT use there banner.
I would like to make my own.
but i am having trouble with reading the array() from the link above.

the only information i really need is in the first array()
Code: Select all
Array
(
    [Protocol] => 17
    [HostName] => [CNS] TFC Server
    [Map] => crossover2
    [ModDir] => tfc
    [ModDesc] => Team Fortress Classic
    [AppID] => 20
    [Players] => 5
    [MaxPlayers] => 16
    [Bots] => 5
    [Dedicated] => d
    [Os] => w
    [Password] => 1
    [Secure] => 1
    [Version] => 1.1.2.2
    [GamePort] => 27015
)
Image
3 posts Page 1 of 1
Return to “Help & Support”