galvin Posted November 30, 2008 Share Posted November 30, 2008 I have finally been able to do a MySQL query from my database to bring back the "teamids" that I need. The array that prints the info below is called "$threeresults". My question is this...how can I create an array that has ONLY the "teamid" values (and eliminates the other stuff)? In other words, I would want an array that has simply [1,2,3,11,17,18,23,27] (which are the 'teamids" from the array info below). Array ( [0] => 1 [teamid] => 1 [1] => 3 [count] => 3 ) Array ( [0] => 2 [teamid] => 2 [1] => 3 [count] => 3 ) Array ( [0] => 3 [teamid] => 3 [1] => 3 [count] => 3 ) Array ( [0] => 11 [teamid] => 11 [1] => 3 [count] => 3 ) Array ( [0] => 17 [teamid] => 17 [1] => 3 [count] => 3 ) Array ( [0] => 18 [teamid] => 18 [1] => 3 [count] => 3 ) Array ( [0] => 23 [teamid] => 23 [1] => 3 [count] => 3 ) Array ( [0] => 27 [teamid] => 27 [1] => 3 [count] => 3 ) Link to comment https://forums.phpfreaks.com/topic/134910-solved-create-a-simplified-array-from-another-array/ Share on other sites More sharing options...
trq Posted November 30, 2008 Share Posted November 30, 2008 My question is this...how can I create an array that has ONLY the "teamid" values (and eliminates the other stuff)? Only select what you need in your query. Link to comment https://forums.phpfreaks.com/topic/134910-solved-create-a-simplified-array-from-another-array/#findComment-702572 Share on other sites More sharing options...
flyhoney Posted November 30, 2008 Share Posted November 30, 2008 Assuming that you executed your query and the result is in $result: <?php $team_ids = array(); while ($row = mysql_fetch_assoc($result) { $team_ids[] = $row['teamid']; } ?> Link to comment https://forums.phpfreaks.com/topic/134910-solved-create-a-simplified-array-from-another-array/#findComment-702574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.