Hi. Can you give sample code for creating runtime ...
# ask-questions
f
Hi. Can you give sample code for creating runtime group for PHP? Because for JS, we should add it with the name "$groups," but in PHP, $, is a special symbol.
f
The attribute name in PHP would still be
$groups
. You just need to either use single quotes or escape the
$
symbol.
Copy code
withAttributes([
  'id' => $userId,
  '$groups' => ["group1"]
]);
f
@ancient-car-96302, for attribute $groups, should I create an attribute in growthbook interface?
@future-teacher-7046
r
Hello, Ihor, you do not need to create an Attribute in the GrowthBook UI if you are using Runtime Saved Groups. This is because membership in the group is determined by your application at runtime, from within your code. Please view our documentation for more info: https://docs.growthbook.io/features/targeting#saved-groups