Adding two or more Custom Attribute(s) by PHP

I am using “Send Push to All Users With Matching Custom Attribute(s)” API to select my target customers.

I am going to select the user by matching the some attribute key but different value. For example, "interest":"finance" or "interest":"entertainment" or "interest":"sports"
As PHP key can only have one value, I cannot push two value into the same key.

so, how can I transform
attribute = {"interest":"finance","interest":"entertainment","interest":"sports"}
into PHP code ?

By using a PHP array:

'attribute' => array('interest' => 'finance', 'interest' => 'entertainment',  'interest' => 'sports')

More detail with sample PHP code can be found here: https://docs.webpushr.com/send-push-to-a-custom-attribute

Thank you for the reply, but I still have some problem.

My code:
'attribute' => array('user_id' => '274474', 'user_id' => '29100'),

Result:


But there are only 1 attempt.

And this is my user attribute:


This should work if both subscribers are active. Let us test this on our end. We will update you shortly.

You were correct and we were wrong. You cannot have duplicate keys in a single PHP array. Try out the following format: This worked in our tests.

"attribute":{"interest":["finance","entertainment","sports"]}

PHP, in your case, as following:

'attribute' => array('user_id' => array(274474, 29100) )