Consider the following MySQL formatted array:
a:14:{s:4:"type";s:6:"select";s:12:"instructions";s:0:"";s:8:"required";i:0;s:17:"conditional_logic";i:0;s:7:"wrapper";a:3:{s:5:"width";s:0:"";s:5:"class";s:0:"";s:2:"id";s:0:"";}s:7:"choices";a:17:{s:14:"2.25mm (B - 1)";s:14:"2.25mm (B - 1)";s:14:"2.75mm (C - 2)";s:14:"2.75mm (C - 2)";s:14:"3.25mm (D - 3)";s:14:"3.25mm (D - 3)";s:13:"3.5mm (E - 4)";s:13:"3.5mm (E - 4)";s:14:"3.75mm (F - 5)";s:14:"3.75mm (F - 5)";s:11:"4mm (G - 6)";s:11:"4mm (G - 6)";s:9:"4.5mm (7)";s:9:"4.5mm (7)";s:11:"5mm (H - 8)";s:11:"5mm (H - 8)";s:13:"5.5mm (I - 9)";s:13:"5.5mm (I - 9)";s:12:"6mm (J - 10)";s:12:"6mm (J - 10)";s:16:"6.5mm (K - 10.5)";s:16:"6.5mm (K - 10.5)";s:12:"8mm (L - 11)";s:12:"8mm (L - 11)";s:14:"9mm (M/N - 13)";s:14:"9mm (M/N - 13)";s:15:"10mm (N/P - 15)";s:15:"10mm (N/P - 15)";s:10:"15mm (P/Q)";s:10:"15mm (P/Q)";s:8:"16mm (Q)";s:8:"16mm (Q)";s:8:"19mm (S)";s:8:"19mm (S)";}s:13:"default_value";a:0:{}s:10:"allow_null";i:0;s:8:"multiple";i:0;s:2:"ui";i:0;s:4:"ajax";i:0;s:11:"placeholder";s:0:"";s:8:"disabled";i:0;s:8:"readonly";i:0;}
How might I go about feeding this data into a PHP array?
This data was grabbed in a WordPress environment using $wpdb->get_results, and the data keeps coming back in an encoded MySQL format. I tried json_decode
but it doesn’t seem to work. Any insight appreciated.
If you use
unserialize
(reference) you will get the following array: