Hello guys,
I'm new here and i recently started php programming and i've come across a problem that i can't seem to solve.
Please help me. I dont know why this error occurs...
i have a file called stats.php were i have a 2D array with a lot of values in.
i get the values from the array by using the key (string)
like this, i.e. $value = $stats["a"]["b"];
further down i have included another file: file2.php.
when im in file2.php some of the array values aren't there anymore...
$stats["a"]["b"] may not have a value in file2.php
why?
so if i make a funtion that returns the stats from file2.php to stats.php
and compares them they are not similar.
stats.php looks something like this:
include('file2.php');
$stats2 = getstats(); //function that returns $stats from file2.php
if($stats["a"]["b"] != $stats2["a"]["b"])
echo "<br/>WHY DOES THIS HAPPEN???<br/>";
hope it makes sense to u...
thx for the help.
Array not the same in included file
Moderator: General Moderators
Re: Array not the same in included file
Ok it works now!?
all i did was to change to another array and use indexes instead of string keys
i did this in stats.php...
$values[1][1] = $stats["a"]["b"];
and used $values array in file2.php instead.
how come this works but not what i had before?
Have you come across something similar? explanation?
all i did was to change to another array and use indexes instead of string keys
i did this in stats.php...
$values[1][1] = $stats["a"]["b"];
and used $values array in file2.php instead.
how come this works but not what i had before?
Have you come across something similar? explanation?