Anidazen Posted November 23, 2006 Share Posted November 23, 2006 Hello.I really hope somebody can help me. I've got a complicated results ordering question.Basically, I've got some prices in an array called $pricearray, and it looks something like this.$pricearray[$i] = array("site logo", "site name", "site url", "site url 2", $sub-price-array);So it's some information about the seller, and $pricearray[4] contains an array of prices for different objects.Now [b]before[/b] the fourth field was turned into an array, I was able to re-order $pricearray via the price contained in value 4 of the array. Someone on this forum was kind enough to supply me with the following code for doing this, months ago.[code]$tmp = array();foreach($pricearray as $k => $v) { $tmp[$k] = $v[8];}asort($tmp);$new = array();foreach($tmp as $k => $v) { $new[] = $pricearray[$k];}[/code]$new would basically be $pricearray but re-ordered based on the value of field number 4 in the array.The problem is I've never understood what's going on in this code, so I'm helpless to adapt it! I need it sorted by the value in $pricearray[4][$i] basically, where $i is the object number.I hope this makes sense.Edit: I believe the 8 in the quoted code should be a 4. This is because $pricearray now has fewer values than when I copied/pasted that bit of code. However, I've tried changing the "$tmp[$k] = $v[8];" into "$tmp[$k] = $v[8][$i];" and it doesn't achieve the desired result. Quote Link to comment Share on other sites More sharing options...
btherl Posted November 24, 2006 Share Posted November 24, 2006 Which element of the sub-price-array do you want to sort by? 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.