1

Looking for some help. Not really familiar with json, especially when they are recursive.

I am working with a WordPress plugin to export the WooCommerce database, including variable product image galleries. I managed to make the export feature work, but need some help with the import. The plugin currently imports what appears to be a json field into the column in question, but I need it to be comma delimited.

I have access to the snippet which calls a lot of wp functions and ultimately creates the string below. I can take that final return and convert it into a comma delimited value but don't know how. All of my json_decode($json) attempts have returned null.

How do I convert:

a:2:{i:0;i:45119;i:1;i:45120;}

to

45119,45120

in php.

Thanks in advance.

tllewellyn
  • 903
  • 2
  • 7
  • 28
  • 2
    That is a [serialized string](https://www.php.net/manual/en/function.serialize.php). You just need to [unserialize it](https://www.php.net/manual/en/function.unserialize.php). – aynber Apr 03 '20 at 22:51
  • Oh, thank you so much! Was completely unfamiliar. With your help, I figured it out in seconds. Please submit this as an answer and I will mark it as such. – tllewellyn Apr 03 '20 at 22:55

0 Answers0