I’m fetching a string from WordPress DB that look’s like this:
a:21:{s:18:"openhours_Sun_text";s:17:"String1";s:19:"openhours_Sun_start";s:4:"9:00";s:17:"openhours_Sun_end";s:5:"22:00"; s:18:"openhours_Mon_text";s:13:"String2";s:19:"openhours_Mon_start";s:4:"9:00";s:17:"openhours_Mon_end";s:5:"22:00"; s:18:"openhours_Tue_text";s:17:"String3";s:19:"openhours_Tue_start";s:4:"9:00";s:17:"openhours_Tue_end";s:5:"22:00"; s:18:"openhours_Wed_text";s:17:"String4";s:19:"openhours_Wed_start";s:4:"9:00";s:17:"openhours_Wed_end";s:5:"22:00"; s:18:"openhours_Thu_text";s:8:"String5";s:19:"openhours_Thu_start";s:4:"9:00";s:17:"openhours_Thu_end";s:5:"22:00"; s:18:"openhours_Fri_text";s:6:"String6";s:19:"openhours_Fri_start";s:4:"9:00";s:17:"openhours_Fri_end";s:5:"16:00"; s:18:"openhours_Sat_text";s:8:"String7";s:19:"openhours_Sat_start";s:5:"19:00";s:17:"openhours_Sat_end";s:5:"23:00";}
How i can transfer it to array in php?
You can use the
maybe_unserialize
function to convert the data to an array.See the codex.