Hey everyone,
I’m trying to finish up a URL router that I created for my custom MVC framework. I have a list of parameters that I dissected from the URL, but the problem is that they only have numerical keys. What I want to do is set it up so the first value in the $params array will be the KEY and then the second value in the array is the VALUE of the first KEY. But I need to take it beyond that even further. Essentially, I need all odd number key’s value in the array to be the new KEY and the even number key’s value to be the value.
Example:
This is how it’s CURRENTLY set up:
Array
(
[0] => greeting
[1] => hello
[2] => question
[3] => how-are-you
[4] => response
[5] => im-fine
)
This is how it NEEDS to be (after conversion):
Array
(
[greeting] => hello
[question] => how-are-you
[response] => im-fine
)
It’s probably a simple solution, because I’m sure this is a common issue, but any enlightenment?
Will be received by such that $_POST or $_GET (depending on the request method) will hold an array of “form” and that array will have your key value pairs.
This cockamamie scheme you’re thinking up right now with the odd / even pairing nonsense is only going to have the maintenance programmer who has to work on your code months from now want to punch you as hard as they can in the face.