This is my post data from front end.
{"camp": 1, "seg": [{"id":15 "rule":[{"id":152},{"id":153, "NAME":"file2"}]},
{"id":16, "rule":[{"id":152, "NAME":"null"}]}
]}
What I need is I do want to check inside the RULE array that It contains an index called NAME or not. if I check like the below code
foreach ($segment as $segementkey => $segmentdata) {
foreach($segmentdata['rule'] as $rulekey => $ruledata){
if ( array_key_exists ($ruledata['NAME'], $ruledata)) {
$is_new = true;
$this->logger->debug('name');
}
else
$this->logger->debug('nooo name');
}
}
I got the error as undefined index NAME. So what is the way to check that the index or element of an array present or not? Thanks in advance