Jump to content

Using a var to prepend an array name


rbrown

Recommended Posts

I have five arrays and I want to be able to select the array used based on the request_uri by prepending the array it is calling.

So if I had

/search/cars/index.php

or

/search/trucks/index.php

And I explode it using / then I want to prepend the name of the array I'm calling

So it would be

$exploded_uri['2']_array would call the $cars_array or $trucks_array depending on the url

 

I'm trying not to use a switch statement.

 

I'm trying to write the code so I can just add a new array to the master array page, create the folder and plop the index.php in and be done without having to mod the page or groups of pages.

 

Can it be done? I have tried a bunch of different ways and I can't get it to work.

Thanks...

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/107401-using-a-var-to-prepend-an-array-name/
Share on other sites

Archived

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

×
×
  • 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.