i’m iterating through and associative array like so:
for (entry in $data[array]) {
// do some stuff
}
i need to assign a value based on the NAME of a key, like so (pseudo-code):
for (entry in $data[array]) {
// do some stuff
if ($data[array][entry]['type'].name = 'thingy') {
// so some other stuff
} else {
// keep doing some stuff
}
}
thing is, i can’t get the zero’th element to cough up its key name such that it can be used as i’ve typed it (i’m aware it doesn’t work…) the array itself looks like this:
$data
(
[success] => 1
[findings] =>
(
[0] =>
(
[type] => thingy
[name] => yo-yo
[age] => 1960
)
[1] =>
(
[type] => doohickey
[name] => clothespin
[age] => 1940
)
)
)
so…essentially what i’m needing to do is do something different if the KEY is a ‘type’. basically for every key of ‘type’, make text red, for example.
what am i missing to make it work? 😛 i hope i’m making myself clear…
WR!
The first value in the
for (key in set)syntax is, in fact, the key.