I have a problem with submitting a PHP form using jQuery Tagify.
If I add 2 tags like John
and Thomas
, then I'm getting $_POST['tag']
as:
'[{"value":"John"}, {"value":"Thomas"}]'
How I can change my $_POST['tag']
to get this POST as: John,Thomas
?
var_dump(implode(', ', array_column(json_decode($_POST['tag']), 'value')));
First you decode the JSON coming in $_POST['tag']
into an array/object structure. array_column
gives you the flat array with the values. Then you join it separated by commas (implode
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With