Re: If Statements Array and Notice Undefined Index
| From: | Al | Date: | Fri, 01 Apr 2011 00:24:32 +0000 |
| Subject: | Re: If Statements Array and Notice Undefined Index | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312184@lists.php.net to get a copy of this message | ||
On 3/31/2011 10:45 AM, Nicholas Cooper wrote:
Good day, I have three arrays A, B and C. Anyone of them might not have the 'id' key set which will give the Notice "Undefined index: id". I just wanted to know what the correct approach to this problem would be; without making the code overly complicated to read by introducing a number of "if isset" statements. if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) { } I have notices switched off, but I want to know the right way to do this. There's probably a number of different right ways to solve this, how would you do it? Best Regards, NicholasCheck out array_intersect_assoc() or one of the similar functions.