Explode serialized data in several columns
-
Hello and thanks for your plugin,
I saw the post here: >> post << but it’s a bit old so I’m wondering if it’s been updated. I’m trying to export values into separate columns from a Tribe Events custom field.
The name of the meta field is: _tribe_tickets_meta.
The form of the field value is:
a:1:{i:21450;a:1:{i:0;a:5:{s:34:"name-to-display-on-the-certificate";s:16:"John Doe";s:19:"massage-association";s:4:"MTAA";s:8:"referral";s:8:"Internet";s:25:"other-massage-association";s:0:"";s:14:"other-referral";s:0:"";}}}
Three fields are interesting for me:
- massage-association
- referral
- other-massage-association
I’ve currently added a PHP hook that allows me to isolate the referral field in my XLS export:
// remove everything around the referral value in the tribe events meta key add_filter('woe_get_order_value__tribe_tickets_meta',function ($value, $order,$fieldname) { $value = strstr($value, 's:8:"'); $end_to_remove = strstr($value, ';s:25:"'); //$value = substr($value, 0, strpos($value, "\";s:25:")); $value = str_replace($end_to_remove,"", $value); $value = str_replace("\"","", $value); $value = str_replace("s:8:referral;s:12:","", $value); $value = str_replace("s:8:referral;s:8:","", $value); $value = str_replace("s:8:referral;s:5:","", $value); $value = str_replace("s:8:referral;s:13:","", $value); $value = str_replace("s:8:referral;s:9:","", $value); return $value; },10,3);
But problem is I can’t do that for each field and have three separate columns onto the same export. Is there a solution?
Thanks!
- The topic ‘Explode serialized data in several columns’ is closed to new replies.