Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: Lookup array by primary key  (Read 2938 times)

0 Members and 1 Guest are viewing this topic.

Offline talkingtoaj

  • Members
  • *
Lookup array by primary key
« on: 16 May 2010, 05:09:40 »
Code: [Select]
_Array = [["a", 5, 4],["b", 2, 3],["c", 6, 1]]
So, if I'm treating the first elements of each array (a, b, c) as a primary key (perhaps refering to the name of a map marker), is there a way to do a lookup where instead of using a forEach loop, I can lookup the element that has primary key, say, "c", and retrieve the associated date (i.e. [6, 1])?

I guess I'm thinking of how we use hash-table lookups in other programming languages. Is it possible, or do we need to brute-force search the entire array using forEach?