I have this code in PHP
$customer->setGroupId($params['group_id']);
I get undefined index group_id error when I run it. I want that if it is undefined then do not throw error but continue the code to work.
How is it possible?
I have this code in PHP
$customer->setGroupId($params['group_id']);
I get undefined index group_id error when I run it. I want that if it is undefined then do not throw error but continue the code to work.
How is it possible?
You can check it with isset() function, for example:
if(isset($params['group_id']) {
$customer->setGroupId($params['group_id']);
}else {
// Something
}
If you want to check for the empty field, you should use empty() function too:
if(!empty($params['group_id']) {
$customer->setGroupId($params['group_id']);
}else {
// Something
}