Forum Moderators: coopster

Message Too Old, No Replies

Declaring arrays

sometimes errors, sometimes not

         

ryan_b83

4:55 pm on Jan 3, 2008 (gmt 0)

10+ Year Member



Hello, I am wondering why the exact same code, one running on 2 different enviornments gives me 2 totally different results.

Windows IIS PHP 4.7...
and one running on
Linux Apache PHP 4.2...

ON WINDOWS:
$someArray[1][1] = "ABC";
echo $someArray[1][1];

RETURNS:
A

ON LINUX:
$someArray[1][1] = "ABC";
echo $someArray[1][1];

RETURNS:
ABC

I then realized that if i declare $someArray[1] = array(), it then works on the Windows version. This is ok except i have a whole bunch of code that works on the Linux enviornment and not the Windows, is there a way to change a setting in the PHP configuration to not force me to have to declare the variables as arrays before attemping to use them?

thanks,
Ryan

coopster

5:34 pm on Jan 3, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Doesn't make sense, really. I wonder if that echo in the Windows version is printing the letter "A" from the first word in "Array" or something? Change the value from "ABC" to "XYZ", make sure you are running the exact same little snippet shown here on both servers and see what your output is.