closer Posted June 3, 2007 Share Posted June 3, 2007 I am having difficulties in getting this correct, what I want to do is sort the prices low to high and display them. That works, but as there are 5 products per page it adds all prices from product 1 to product 2, all prices from product 1 and 2 to product 3 etc.. How to tell php that the array needs to be reset / cleared / set to zero when done with product 1 / product 2 ....? I've tried reset ($ar) and unset ($ar) but both won't work $ar = array( $this->_movieValues['1'] => $row['1price'], $this->_movieValues['2'] => $row['2price'], $this->_movieValues['3'] => $row['3price'], $this->_movieValues['4'] => $row['4price'], $this->_movieValues['5'] => $row['5price'], $this->_movieValues['6'] => $row['6price'], $this->_movieValues['7'] => $row['7price'], $this->_movieValues['8'] => $row['8price'], $this->_movieValues['9'] => $row['9price']); asort ($ar); foreach ($ar as $key => &$val){ $this->_movieValues['sorted'] .="$key"; } Any help on this matter is much appreciated.. Link to comment https://forums.phpfreaks.com/topic/54071-resetting-clearing-array-how-to/ Share on other sites More sharing options...
tail Posted June 3, 2007 Share Posted June 3, 2007 http://us.php.net/manual/en/ref.array.php Link to comment https://forums.phpfreaks.com/topic/54071-resetting-clearing-array-how-to/#findComment-267286 Share on other sites More sharing options...
closer Posted June 3, 2007 Author Share Posted June 3, 2007 Thank you for your brief answer, though I already know the PHP.net manual site and need some "human" input as it did not help me, the reset($ar) and unset($ar) were in fact 2 suggestions from php.net which clearly do not apply to this other input would be appreciated Link to comment https://forums.phpfreaks.com/topic/54071-resetting-clearing-array-how-to/#findComment-267336 Share on other sites More sharing options...
chigley Posted June 3, 2007 Share Posted June 3, 2007 Umm.. try this: foreach($ar as $key => $val) { unset($val); } Link to comment https://forums.phpfreaks.com/topic/54071-resetting-clearing-array-how-to/#findComment-267350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.