jpeterson579's avatar

Unsupported operand types? How to solve?

I am getting Unsupported operand types only when $array01 is empty... How do I get around this?

//Array for the a newly create group
$newgroup = array();
$newgroup = array_add($newgroup, $justcreated_group, '1');

//Array for existing group selections
$array01 = Input::get('group_ids');

//Merge the 2 (give me Unsupported operand types when array01 is empty)
$merge = $newgroup + $array01;

$finalarray = array_keys($merge);
0 likes
8 replies
eszterczotter's avatar

Is it possible, that $array01 isn't empty, but null, when you get the error?

RachidLaasri's avatar

Use this line to see the content of the $array01 variable, i think it's either empty or not an array.

dd($array01);
RachidLaasri's avatar
Level 41
$array01 = Input::get('group_ids') == null ? [] : Input::get('group_ids');
thepsion5's avatar

Even simpler:

$array01 = Input::get('group_ids', []);
4 likes

Please or to participate in this conversation.