JREAM Posted February 16, 2009 Share Posted February 16, 2009 THis is a weird question I am trying to sort out. I got this that makes an array right, But i want to sort the output before its printed: I need the variable so I can sort($position) for the output foreach ($output as $value) { // How do I grab the $position from // $output[$i] so I can $sort($position) echo $value; } (I just removed stuff to make it shorter, it works) while (//etc..) { // Removed stuff here to make it shorter $output[$i] = "<tr> <td style='padding: 5px;'>$position</td> <td style='padding: 5px;'>$title</td> </tr>"; } PS: How do i mark something as solved ?? Link to comment https://forums.phpfreaks.com/topic/145445-solved-grabbing-a-variable-out-of-an-array/ Share on other sites More sharing options...
Mchl Posted February 16, 2009 Share Posted February 16, 2009 Why don't you use sort? The 'mark as solved' should be below somewhere next to 'reply' button. Link to comment https://forums.phpfreaks.com/topic/145445-solved-grabbing-a-variable-out-of-an-array/#findComment-763518 Share on other sites More sharing options...
wildteen88 Posted February 16, 2009 Share Posted February 16, 2009 EDIT: Umm beaten to it Sort the array before the foreach loop, eg asort($output); foreach ($output as $value) { // How do I grab the $position from // $output[$i] so I can $sort($position) echo $value; } PS: How do i mark something as solved ?? You should see a TOPIC SOLVED link just above the Quick reply box. Link to comment https://forums.phpfreaks.com/topic/145445-solved-grabbing-a-variable-out-of-an-array/#findComment-763522 Share on other sites More sharing options...
JREAM Posted February 16, 2009 Author Share Posted February 16, 2009 Oh i use asort BEFORE the thing, cool!! ty! Link to comment https://forums.phpfreaks.com/topic/145445-solved-grabbing-a-variable-out-of-an-array/#findComment-763537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.