将数组值插入到html表中

时间:2013-05-12 15:35:54

标签: php html arrays

我正在尝试从数组中插入某些值,这是查询扫描的结果。该数组如下所示:

Array ( 
[PERP] => Array ( 
[Lee_AttachViewModelToView] => 0 
[Lee_WeaponAutoReload] => 0 
[Lee_WeaponDamageMul] => 1 
[Lee_WeaponEDC] => 3 
[Lee_WeaponEDT] => 1 
[Lee_WeaponHitEffect] => 0 
[Lee_WeaponInfiniteAmmo] => 0 
[Lee_WeaponRecoilMul] => 1.4 
[Lee_WeaponShakeMul] => 5 
[Lee_WeaponViewKick] => 1 
[Lee_WeaponsSpeed] => 1 
[ai_disabled] => 0 
[ai_ignoreplayers] => 0 
[coop] => 0 
[deathmatch] => 1 
[decalfrequency] => 10 
[dedicated] => d 
[game_descr] => sandbox
[game_dir] => garrysmod 
[gq_address] => 192.168.1.1 
[gq_dedicated] => d 
[gq_gametype] => 
[gq_hostname] => Test server 
[gq_mapname] => gm_construct
[gq_maxplayers] => 60 
[gq_mod] => garrysmod 
[gq_numplayers] => 8 
[gq_online] => 1 
[gq_password] => 0 
[gq_port] => 27016 
[gq_protocol] => source 
[gq_transport] => udp 
[gq_type] => gmod 
[hostname] => Test server
[map] => gm_construct 
[max_players] => 60
[mp_allowNPCs] => 1 
[mp_autocrosshair] => 1 
[mp_fadetoblack] => 0 
[mp_falldamage] => 0 
[mp_flashlight] => 1 
[mp_footsteps] => 1 
[mp_forcerespawn] => 1 
[mp_fraglimit] => 0 
[mp_friendlyfire] => 0 
[mp_teamlist] => hgrunt;scientist 
[mp_teamplay] => 0 
[mp_timelimit] => 0 
[mp_weaponstay] => 0 
[nextlevel] => 
[num_bots] => 0 
[num_players] => 8 
[num_rules] => 98 
[os] => w 
[password] => 0 
[physgun_limited] => 0 
[players] => Array ( 

    [0] => Array ( 

        [id] => 0 
        [name] => Supreme Leader Aladeen 
        [score] => 3 
        [time] => 17884.9082031 
        [gq_name] => Supreme Leader Aladeen 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 3 
        [gq_ping] => ) 

    [1] => Array ( 

        [id] => 0 
        [name] => [ZFrag] SpeedDemon 
        [score] => 1 
        [time] => 7439.12109375 
        [gq_name] => [ZFrag] SpeedDemon 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 1 
        [gq_ping] => ) 

    [2] => Array ( 

        [id] => 0 
        [name] => [ZFrag] Swiper The Fox 
        [score] => 0 
        [time] => 7159.75634766 
        [gq_name] => [ZFrag] Swiper The Fox 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 0 
        [gq_ping] => ) 

    [3] => Array ( 

        [id] => 0 
        [name] => {MG} attacker1983 
        [score] => 0 
        [time] => 3252.78735352 
        [gq_name] => {MG} attacker1983 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 0 
        [gq_ping] => ) 

    [4] => Array ( 

        [id] => 0 
        [name] => rolisrolis7 
        [score] => 1 
        [time] => 3240.36376953 
        [gq_name] => rolisrolis7 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 1 
        [gq_ping] => ) 

    [5] => Array ( 

        [id] => 0 
        [name] => T-Bone Jackson 
        [score] => 0 
        [time] => 2755.24243164 
        [gq_name] => T-Bone Jackson 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 0 
        [gq_ping] => ) 

    [6] => Array ( 

        [id] => 0 
        [name] => Maxen #Unban Odx <3 
        [score] => 0 
        [time] => 1802.96948242 
        [gq_name] => Maxen #Unban Odx <3 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 0 
        [gq_ping] => ) 

    [7] => Array ( 

        [id] => 0 
        [name] => the pro pingvin 
        [score] => 0 
        [time] => 814.78704834 
        [gq_name] => the pro pingvin 
        [gq_kills] => 
        [gq_deaths] => 
        [gq_score] => 0 
        [gq_ping] => ) ) 

[protocol] => 17 
[r_AirboatViewDampenDamp] => 1.0 
[r_AirboatViewDampenFreq] => 7.0 
[r_AirboatViewZHeight] => 0.0 
[r_JeepViewDampenDamp] => 1.0 
[r_JeepViewDampenFreq] => 7.0 
[r_JeepViewZHeight] => 10.0 
[r_VehicleViewDampen] => 0 
[sb_version] => 1.531 
[sbox_bonemanip_misc] => 0 
[sbox_bonemanip_npc] => 1 
[sbox_bonemanip_player] => 0 
[sbox_godmode] => 1 
[sbox_maxballoons] => 100 
[sbox_maxbuttons] => 50 
[sbox_maxdynamite] => 10 
[sbox_maxeffects] => 200 
[sbox_maxemitters] => 20 
[sbox_maxhoverballs] => 50 
[sbox_maxlamps] => 3 
[sbox_maxlights] => 5 
[sbox_maxnpcs] => 10 
[sbox_maxprops] => 200 
[sbox_maxragdolls] => 10 
[sbox_maxsents] => 300 
[sbox_maxspawners] => 10 
[sbox_maxthrusters] => 50 
[sbox_maxturrets] => 4 
[sbox_maxvehicles] => 3 
[sbox_maxwheels] => 50 
[sbox_noclip] => 1 
[sbox_persist] => 
[sbox_playershurtplayers] => 1 
[sbox_weapons] => 1 
[secure] => 1 
[sensor_debugragdoll] => 0 
[sensor_stretchragdoll] => 0 
[steamappid] => 4000 
[sv_accelerate] => 10 
[sv_airaccelerate] => 10 
[sv_allowcslua] => 0 
[sv_alltalk] => 0 
[sv_bounce] => 0 
[sv_cheats] => 0 
[sv_contact] => 
[sv_footsteps] => 1 
[sv_friction] => 8 
[sv_gravity] => 600 
[sv_hl2mp_item_respawn_time] => 30 
[sv_hl2mp_weapon_respawn_time] => 20 
[sv_maxspeed] => 10000 
[sv_noclipaccelerate] => 5 
[sv_noclipspeed] => 5 
[sv_password] => 0 
[sv_pausable] => 0 
[sv_report_client_settings] => 0 
[sv_rollangle] => 0 
[sv_rollspeed] => 200 
[sv_specaccelerate] => 5 
[sv_specnoclip] => 1 
[sv_specspeed] => 3 
[sv_steamgroup] => 
[sv_stepsize] => 18 
[sv_stopspeed] => 10 
[sv_voiceenable] => 1 
[sv_wateraccelerate] => 10 
[sv_waterfriction] => 1 
[teams] => Array ( ) 
[tv_enable] => 0 
[tv_password] => 0 
[tv_relaypassword] => 0 
[version] => 49 ) )

我只想从中挑选某些值; gq_type,gq_online,gq_hostname,gq_address,gq_port,gq_numplayers,gq_mapname。

我想按照上面的顺序将这些插入到一行的html表中。

问候。

1 个答案:

答案 0 :(得分:0)

我认为您可以在数组中循环,然后在表格中打印所需的数据

<table cellpadding="0" cellspacing="0" border="0">
  <tr>
  <?php foreach($array as data) { ?>
    <td><?php echo $data['gq_type']; ?></td>
    <td><?php echo $data['gq_online']; ?></td>
    <td><?php echo $data['gq_hostname']; ?></td>
    <td><?php echo $data['gq_address']; ?></td>
    <td><?php echo $data['gq_port']; ?></td>
    <td><?php echo $data['gq_numplayers']; ?></td>
    <td><?php echo $data['gq_mapname']; ?></td>
  <?php } ?>
  </tr>
</table>