Im working on a Hotel Reservtion script and ran into a little problem:
I have 3 types of rooms, 1 is Single, 2 is Double, 3 is Suite
for this reason, $totaltypes = '3'; (in the snippet below).
I have a form with checkboxes in order to reserve rooms, all rooms that are checked are saved in the array @All_Rooms as detailed below:
Expand|Select|Wrap|Line Numbers
- = ("1-101", "1-102","2-201", "2-202","3-301", "3-302");
2-201 means that room number 201 belongs to type 2 (being a double room).
and so forth.
Now I need to remove all room numbers from the array @All_Rooms and put them in separate arrays by room type. In other words all rooms beginning with 1- would go in one array, all rooms beginning with 2- would go on another, and so forth.
Except I never know how many room types will be, the script checks out this number by veryfying how many room type files have been created and assign it to the scalar $totaltypes.
I tryed the following code but it doesnt work... what am I doing wrong..??
Expand|Select|Wrap|Line Numbers
- for($b=1; $b<=$totaltypes; $b++)
- {
- foreach $room (@all_rooms){
- @splitted_room = split (/\-/, $room);
- if($splitted_room[0] == $b){
- push(@Reserved_Rooms[$b], $splitted_room[1]);
- }
- }
- }
VirtualWeb