从数组中提取项目

时间:2013-01-28 09:58:20

标签: php arrays

我希望能够在PHP中从此数组中提取[HostName]的输出。谢谢!

Array
(
    [Protocol] => 17
    [HostName] => [HG] JAILBREAK #1 - HeLLsGamers.com | 30+ LR's | FastDL
    [Map] => ba_jail_hellsgamers_fx6
    [ModDir] => cstrike
    [ModDesc] => Counter-Strike: Source
    [AppID] => 240
    [Players] => 12
    [MaxPlayers] => 64
    [Bots] => 0
    [Dedicated] => d
    [Os] => l
    [Password] => 
    [Secure] => 1
    [Version] => 1.0.0.75
    [GamePort] => 27015
    [ServerID] => -682722125
    [GameTags] => HLstatsX:CE,alltalk,bunnyhopping,cool,drugs,free,gameme,gang,hellsgamers,hg,increased_maxplayers,jail,jailbr,nostats,startmoney
)

2 个答案:

答案 0 :(得分:1)

像这样:

echo $Array[HostName]; // output: [HG] JAILBREAK #1 - HeLLsGamers.com | 30+ LR's | FastDL

其中$Array是您在此打印和复制的数组。

我建议您开始阅读php.net中的内容 - 因为这是您可以做的最基本的事情。

答案 1 :(得分:1)

这是最简单的问题......... 只需使用此

echo $Your_array[HostName];