ghostwalkz Posted May 14, 2008 Share Posted May 14, 2008 Hi all, I have an array that spits out the array below when I use this code: print_r($data[$server_id]); Now all I want to show is the Players name and their honor level. (near the bottom). How can I do that? :'( Array ( [hostname] => ACI | UNITEDGODZ.COM [gamename] => armygame [gamever] => 2.8.3.1 [hostport] => 1716 [mapname] => Insurgent Camp [gametype] => AAGP_GameTeamObjective [numplayers] => 6 [numteams] => 2 [maxplayers] => 24 [gamemode] => openplaying [password] => 0 [tour] => 3 [official] => 1 [leased] => 1 [nato] => 0 [miles] => 0 [cheats] => 0 [minhonor] => 11 [maxhonor] => 100 [groups] => ALL [current_round] => 9/15 [mission_time] => 3:49 [sv_punkbuster] => 1 [tournament] => 0 [explore_the_army] => 0 [thirdparty] => 0 [custom] => Array ( [address] => 209.246.170.84 [query_port] => 1717 [id] => aa [type] => spy [name] => America's Army: Operations [ping] => 110 ) [AdminName] => www.UnitedGodz.com [AdminEMail] => UGCOMPLAINTS@HOTMAIL.COM [requires_authorization] => 1 [coop] => 0 [average_honor] => 49 [current_round_int] => 9 [rounds_per_match] => 15 [locale] => (unknown) [operating_system] => Windows Server 2003 5.2 (Build: 3790) [average_player_ping] => 38 [mission_time_remaining] => 229 [score_t0] => 6 [score_t1] => 2 [final] => [queryid] => 1.1 [players] => Array ( [0] => Array ( [leader] => 60 [goal] => 150 [honor] => 44 [player] => killer1killer [ping] => 69 [roe] => 0 [kia] => -30 [enemy] => 70 [score] => 250 [pbguid] => 7c795daff1040f6839d09d74aec12239 ) [1] => Array ( [leader] => 40 [goal] => 135 [honor] => 54 [player] => kozilla [ping] => 35 [roe] => 0 [kia] => -30 [enemy] => 80 [score] => 225 [pbguid] => 77fb31c63791161a5cc5bc03a1ce5818 ) [2] => Array ( [leader] => 30 [goal] => 60 [honor] => 16 [player] => fastzaar [ping] => 43 [roe] => 0 [kia] => -40 [enemy] => 10 [score] => 90 [pbguid] => 9bfaf1b74c5a417d328fe7f53acfb25d ) [3] => Array ( [leader] => 10 [goal] => 30 [honor] => 43 [player] => bestman [ping] => 38 [roe] => 0 [kia] => -70 [enemy] => 30 [score] => 40 [pbguid] => 50b1bc24c83589b009108aa92735747a ) [4] => Array ( [leader] => 0 [goal] => 30 [honor] => 99 [player] => -eTc.motosport^EST [ping] => 36 [roe] => 0 [kia] => -30 [enemy] => 30 [score] => 30 [pbguid] => aa32ca1565c3b9d245de910bc7faba00 ) [5] => Array ( [leader] => 0 [goal] => 0 [honor] => 39 [player] => kicking-in_heads [ping] => 11 [roe] => 0 [kia] => 0 [enemy] => 0 [score] => 0 [pbguid] => 5507775a75a314fa2c9f5d0c31c2dd0d ) ) ) Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 14, 2008 Share Posted May 14, 2008 <?php echo $data[$server_id['honor']]; echo $data[$server_id['player']]; ?> I'm tired, but thats a guess lol ACE Quote Link to comment Share on other sites More sharing options...
ghostwalkz Posted May 14, 2008 Author Share Posted May 14, 2008 Thanks for the idea, but that hasnt worked, Its like a nested array, with more than 1 player per nest, how can I just extract the Player name and honor, leaving everything else? This is driving me nuts! :'( Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 14, 2008 Share Posted May 14, 2008 this will echo their details <?php foreach($data[$server_id]['players'] as $p) { echo $p['player']; echo "<br>"; echo $p['honor']; } ?> time for bed MasterACE14 lol EDIT: if you print_r($data[$server_id]['players']); you should get * => Array ( [leader] => 60 [goal] => 150 [honor] => 44 [player] => killer1killer [ping] => 69 [roe] => 0 [kia] => -30 [enemy] => 70 [score] => 250 [pbguid] => 7c795daff1040f6839d09d74aec12239 ) [1] => Array ( [leader] => 40 [goal] => 135 [honor] => 54 [player] => kozilla [ping] => 35 [roe] => 0 [kia] => -30 [enemy] => 80 [score] => 225 [pbguid] => 77fb31c63791161a5cc5bc03a1ce5818 ) [2] => Array etc etc what the foreach does it set P to each player ie [leader] => 60 [goal] => 150 [honor] => 44 [player] => killer1killer [ping] => 69 [roe] => 0 [kia] => -30 [enemy] => 70 [score] => 250 [pbguid] => 7c795daff1040f6839d09d74aec12239 then you echo the item ie player = killer1killer hope that makes sense Quote Link to comment Share on other sites More sharing options...
ghostwalkz Posted May 14, 2008 Author Share Posted May 14, 2008 MadTechie! You have only gone and done it. Thanks mate, perfect! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 14, 2008 Share Posted May 14, 2008 welcome (can you click solved) (if its their) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.