Hi
Have a quick query...
I am developing a website that provides information about cars in a particular city (not really cars, but the principles will be the same).
The page which displays the cars is basically: show_cars.php?city=nyc&car=001
The first time a user loads a NYC page, the show_cars script retrieves the NYC cars from mysql and stores them in an array called nyc_cars_array. The cars are then listed in a select/option dropbown box. I have set up the arrays to prevent the need for continuing to pull out the list of NYC cars from the database whenever the page is reloaded.
A real quick synopsis of the code would be:
$city = $HTTP_GET_VARS['city'];
Then assuming the city was NYC I would want to check to see if the NYC array had been set.
if (!isset($HTTP_SESSION_VARS['nyc_car_array']))
{
$nyc_car_array = get_car_array(nyc);
$HTTP_SESSION_VARS['nyc_car_array'] = $nyc_car_array;
}
However, I do not want to have to create one of the above if-isset arguments for each city. Is there some way I can insert the $city variable into the argument?
For instance, it would be:
if (!isset($HTTP_SESSION_VARS['$city_car_array']))
{
$$city_car_array = get_car_array($city);
$HTTP_SESSION_VARS['$city_car_array'] = $$city_car_array;
}
The above clearly does not work as I have just substituted $city for NYC. There must be someway to do this.
Thanks,
MD