I am afraid that FormData will always convert your values to string, if it is not a Blob or a File type.
Check this StackOverflow answer, you solved your issue the right way, but I guess this has nothing to do with PHP (you would have the same issue with a NodeJS backend for instance).
Tips for your client side payload
You can take advantage of JSON.stringify to encode your data:
I am afraid that
FormDatawill always convert your values to string, if it is not aBlobor aFiletype.Check this StackOverflow answer, you solved your issue the right way, but I guess this has nothing to do with PHP (you would have the same issue with a NodeJS backend for instance).
Tips for your client side payload
You can take advantage of
JSON.stringifyto encode your data:Decode your payload seemlesly server side
I found this GitHub issue, with an interesting solution. I adapted it to make this seemless in your actual code:
Hope it helps!