Posted by bobmct on 02/16/06 20:18
Fellow PHP'ers;
I'm digging myself a hole on this one so I thought it has come to the
time when I must ask those who know.
I have what should be a simple question for loading, accessing and
retrieving values stored in a simple one-dimensional array.
I am simply trying to determine the occurrence of numbers as they
appear in a file. For example lets assume the lowest allowed value is
(00) and the highest allowed value is (35) and the numbers could occur
from zero to n times over the course of a period of time.
The problem I am having is referencing the array elements as strings
but it appears in reality its being references as a vector/index.
I am creating the array with:
$array_name=array();
then I am incrementing the count with:
$X=the number I've parsed from the file;
$array_name[$X]++;
then at the end I am using a for loop to print it out:
for($X=0;$X<=highest_allowed_value;$X++) {
print $X, $array_name[$X];
}
Of course, my field names are different and I think that the
references to the $X in the brackets are being interpreted as numeric
vectors but when I try to convert them to a string and use them it
also fails.
Can someone PLEASE set me straight on the proper technique to
accomplish this? As much as I've used PHP over the years I usually
have no issues with arrays except when I need strict numeric indexing.
Go figure.
Corrections? Suggestions? Advise? Anyone??
Thank you so much.
Signed: Frustrated PHP'er...
Navigation:
[Reply to this message]
|