Page 1 of 1

array with index surounded with ' or "

Posted: Thu Feb 10, 2005 7:56 am
by pelegk2
i have for exampel an array :

array =
'23368': array =
makat: string = "23368"
qnt: string = "6.00"
weight: string = "44.40"
date: long = 1107900000
'24651': array =
makat: string = "24651"
qnt: string = "6.00"
weight: string = "26.64"
date: long = 1107900000
when i try to access this arrat that's called arr1["23368"] i get undefined!
why is that? isnt this both are strings?

Posted: Thu Feb 10, 2005 8:09 am
by feyd
uhm, you know this is a php board right?

Moved to Misc. :roll:

yes

Posted: Thu Feb 10, 2005 8:29 am
by pelegk2
what seem's to be the problem

Posted: Thu Feb 10, 2005 8:34 am
by feyd
first off, what language is this? It's obviously not php. Second, I don't see arr1 mentioned anywhere in that "code"

Posted: Thu Feb 10, 2005 9:21 am
by n00b Saibot
i think he has tried to give an 'exampel' of var_dump output of his array!
right pelegk2! :wink:

I tried this in a snippet. i think his array maybe like this

Code: Select all

$arr = 
array(
 '23368'=>
   array(makat=>"23368",
         qnt=>"6.00",
         weight=>"44.40",
         date=>1107900000
            )
 ,
 '24651'=>
   array(makat=>"24651",
            qnt=>"6.00",
            weight=>"26.64",
            date=>1107900000
            )
 )
);
which produces

Code: Select all

array(2) {
  ї23368]=>
  array(4) {
    ї"makat"]=>
    string(5) "23368"
    ї"qnt"]=>
    string(4) "6.00"
    ї"weight"]=>
    string(5) "44.40"
    ї"date"]=>
    int(1107900000)
  }
  ї24651]=>
  array(4) {
    ї"makat"]=>
    string(5) "24651"
    ї"qnt"]=>
    string(4) "6.00"
    ї"weight"]=>
    string(5) "26.64"
    ї"date"]=>
    int(1107900000)
  }
}
..and I am able to get correct values by using $arr['23368'][makat] which gives correct output > 23368.

well

Posted: Sun Feb 13, 2005 1:04 am
by pelegk2
that an output i havre copied from th immediate window
and i wanted to show an array i could'nt access
i will try try [23368] thing (the number as a number and not as a string ['23368'] :)