Stack Overflowers,
Having attempted to dive into PHP, I appear to have got stuck; I have a pre-generated array where var_dump($codes) is as follows:
array(2) {
[0]=>
array(3) {
["code"]=>
string(5) "01332"
["description"]=>
string(19) "Derby Discount Code"
["discount_amount"]=>
string(2) "15"
}
[1]=>
array(3) {
["code"]=>
string(5) "01283"
["description"]=>
string(25) "South Derby Discount Code"
["discount_amount"]=>
string(2) "20"
}
}
I have form which _POSTs a variable of $code and would like to search in the array above to see if there is a match for $code in one of the nested arrays above. If so, I would like to be able to get the discount amount and description as individual variables.
So far I have the following:
if(in_array($code, $codes)) {
//apply discount code using $discount_amount
}
where $codes outputs the array posted at the top of this question.