Jump to content

Array Lookup Table


JustinK101

Recommended Posts

I have an array filled with custom keys and values like so:

Array ( [_other_unknown_sic] => Other - Unknown SIC [acoustical_contractors_174202] => Acoustical Contractors 1742-02 [aerospace_381201] => Aerospace - 3812-01 )

How can I do an IF statement to look for a given key, call it myKey in the array of keys, and if a match is found return the value correspoding to the matched key.

Thanks
Link to comment
https://forums.phpfreaks.com/topic/35709-array-lookup-table/
Share on other sites

SemiApocalyptic:

Does this look right, just expanded one value into a whole lot of values from mysql.

while($row = mysql_fetch_assoc($result))
{
if(array_key_exists($row['sic_c'], $myArray))
{
$sql = "UPDATE leads_cstm SET sic_custom_c = '" . $myArray[$row['sic_c']] . "' WHERE id = '" . $row['id'] . "' LIMIT 1";
mysql_query($sql) or die(mysql_error());
}
}
Link to comment
https://forums.phpfreaks.com/topic/35709-array-lookup-table/#findComment-169185
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.