Convert MySQL array format to PHP array -
this question has answer here:
- string / array format convert php 2 answers
consider 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 go feeding data php array?
this data grabbed in wordpress environment using $wpdb->get_results, , data keeps coming in encoded mysql format. tried json_decode
doesn't seem work. insight appreciated.
if use unserialize
(reference) following array:
array ( [type] => select [instructions] => [required] => 0 [conditional_logic] => 0 [wrapper] => array ( [width] => [class] => [id] => ) [choices] => array ( [2.25mm (b - 1)] => 2.25mm (b - 1) [2.75mm (c - 2)] => 2.75mm (c - 2) [3.25mm (d - 3)] => 3.25mm (d - 3) [3.5mm (e - 4)] => 3.5mm (e - 4) [3.75mm (f - 5)] => 3.75mm (f - 5) [4mm (g - 6)] => 4mm (g - 6) [4.5mm (7)] => 4.5mm (7) [5mm (h - 8)] => 5mm (h - 8) [5.5mm (i - 9)] => 5.5mm (i - 9) [6mm (j - 10)] => 6mm (j - 10) [6.5mm (k - 10.5)] => 6.5mm (k - 10.5) [8mm (l - 11)] => 8mm (l - 11) [9mm (m/n - 13)] => 9mm (m/n - 13) [10mm (n/p - 15)] => 10mm (n/p - 15) [15mm (p/q)] => 15mm (p/q) [16mm (q)] => 16mm (q) [19mm (s)] => 19mm (s) ) [default_value] => array ( ) [allow_null] => 0 [multiple] => 0 [ui] => 0 [ajax] => 0 [placeholder] => [disabled] => 0 [readonly] => 0 )
Comments
Post a Comment