Jump to content

sorting a session


richie_ropey

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
Link to comment
Share on other sites

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.