What happens in the first code is that $server['url] will return only http://, not the rest. $server['current_url'] returns a blank. I believe what is going on is that you can't access a key until after the array() is closed. I need to confirm this. It would make no sense to me for this to be the case. I am hoping that I am doing something incorrectly, but it gets through the parser somehow.

If you could point me to something somewhere that says you can't do what I did in the first example (somewhere like php.net), I would appreciate it. I would much rather do things the way I want the first example to function. This example would be relatively easy to change each value to the one I want, but for readability's sake I don't want to. I do have much more complicated variables built on a similar fashion that would be a bugger to do.

Inigoesdr

10-28-2007, 02:42 AM

The first doesn't work because $server['name'] doesn't have a value yet when you try to use it. The array hasn't been defined yet and you're trying to call it. You have to use the second method if you want to define the array using those values.

Blue_Jeans

10-28-2007, 02:53 AM

Great... just great...
Is there a similar syntax I can use to the first to accomplish what I want? I don't think there is but I'm hoping... It is much easier to use the first syntax because if I ever change the name of the variable, the first syntax makes it easy. Change one tag, you have them all. The second... I'd have to edit a quite a lot of lines of code.

Inigoesdr

10-28-2007, 05:28 PM

No, not if you intend to use the value of one index in another like that.

CFMaBiSmAd

10-28-2007, 06:07 PM

The first form does not satisfy your argument (assuming it worked) of changing the name in one place either. You must change it three places inside of the array() statement in addition to the left-hand side of the assignment -