Jump to content

Archived

This topic is now archived and is closed to further replies.

richie_ropey

sorting a session

Recommended Posts

hi, i have some code

[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;

[/code]

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

Share this post


Link to post
Share on other sites

×

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.