I have an array with $post_id as keys. When save the $data, I saved it as a string:
foreach( $data as $post_id => $details )
$string .= "-pid-$post_id-$details";
When use the data, I need to convert it back to array with $post_id as key and $details as value. How to explode it when I don't know what is the $post_id ?
Don't do it this way. if you need to serialize a string use json_encode():
$string = json_encode($data);
Then, when you need to decode it again:
$data = json_decode($string);
Safe and easy.
Here's the PHP reference: json_encode()
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