array with index surounded with ' or "

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

array with index surounded with ' or "

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uhm, you know this is a php board right?

Moved to Misc. :roll:
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

yes

Post by pelegk2 »

what seem's to be the problem
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

first off, what language is this? It's obviously not php. Second, I don't see arr1 mentioned anywhere in that "code"
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

well

Post 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'] :)
Post Reply