$_SESSION["rooms"][1] = array("room_name"=>"Bob's Room", room_status=>1)
$_SESSION ["rooms"][2] = array("room_name"=>"Jeff's Room", room_status=>0)

then for a given room_id ...
echo($_SESSION [$room_id]["room_name"]) and so on

Tim Ward
Internet Chess www.chessish.com <http://www.chessish.com> 

        From:  Nathan [SMTP:[EMAIL PROTECTED]]
        Sent:  13 May 2002 17:47
        To:  PHP
        Subject:  An array of objects?

        I have some data I need to store in the session array and I'm not
exactly sure how to get it there
        and get it back... I have a list of room ID numbers, and each room
ID has a few attributes I need to
        keep track of. I end up with a listing like so:

        room_id = 1, room_name = "Bob's Room", room_status = 1
        room_id = 2, room_name = "Jeff's Room", room_status = 0

        Room_id is unique, room_name is a string, and room_status is
boolean. There are on average 30 rooms
        that need to be kept track of. I'd like to put all this data in the
session array so I don't have to
        query my database every time the page reloads, which will happen
fairly often. If the data is in the
        session, then I can simply update the room_status where I need to
without fetching everything again.

        Anyway, I am having a really hard time figuring out how to keep
track of all this data, and I've
        looked at it so long I'm sure I'm making far more complex that

        I've attempted to create an array of objects but I get warnings
whenever I try to refer to
        $myObject[$1]->status or anything like that. I've also tried a 4D
array, but I am doing something
        very wrong trying to reference the data... Anyone got ideas here?

        Many thanks!

        # Nathan

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to