Jump to content

Recommended Posts

 

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.