Jump to content


Photo

sorting a session


  • Please log in to reply
No replies to this topic

#1 richie_ropey

richie_ropey
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 16 March 2006 - 04:34 PM

hi, i have some code

        
$j = 0;
    if (isset($_SESSION['c_a_num_fields']))
    {
        for ($i=0; $i < $_SESSION['c_a_num_fields']; $i++)
        {
            if (isset($_SESSION['c_asset_value_'.$i.'']))
            {
                $sort[$j] = $_SESSION['c_asset_value_'.$i.''];
                $j++;
            }
        }

        for ($i=0; $i < $_SESSION['c_a_num_fields']; $i++)
        {
            $_SESSION['c_asset_value_'.$i.''] = $sort[$i];
        }
    }

$j = 0;


this idea of this code is to sort $_SESSION['c_asset_value_'.$i.''] so that $i goes:
1
2
3
4
5

instead of
1
3
4
5
8

(just an example), the reason for this happening is to do with deleting cirtain sessions, mainly cause i dont want to use the database for this sort of stuff.

this code dosnt work (though i think the logic looks good :|), i was wondering if theres:
a) anyway to fix the current code
b) alternative code
c) a session function to do this for me (ive looked in the php manual and saw somthing about session_regenerate_id, but i dont understand how it works)

thanks - Rich




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users