Jump to content

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

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.