Concatenation with addition in it doesn’t work as expected

+ and . have the same operator precedence, but are left associative. Means after the first concatenation:

'(' . (int)$data['event_id']

The string got added with your key, e.g.

"($data['event_id']" + $key

So the string gets converted into an integer in that numerical context and disappears. To solve this use parentheses () around your addition.

Leave a Comment