https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
f

full-receptionist-33755

12/17/2023, 9:25 AM
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

future-teacher-7046

12/17/2023, 4:10 PM
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

full-receptionist-33755

12/18/2023, 9:32 AM
@ancient-car-96302, for attribute $groups, should I create an attribute in growthbook interface?
@future-teacher-7046
r

rhythmic-agent-34208

12/19/2023, 10:05 PM
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
3 Views