What is this data format?

Bes

Bes

Soldato
Joined
18 Oct 2002
Posts
7,318
Location
Melbourne
Hi

I have a data format as follows, it does not seem to be a standard PHP or JSON serialized datatype. Neither method of unserializing it seems to work:

(This is a sample and returned from a payment gateway).

PHP:
a:2:{s:16:"authAmountString";s:10:"£33.39";s:11:"_SP_charEnc";s:5:"UTF-8";}

Any ideas what this is and how I can turn it into an array? (I am fetching it from a MySQL text field)

Thanks
 
Last edited:
Yes exactly it is missing the index elements so I cannot unserialize it,

Also I made a typo with the a: value, but still it's not a valid anything format it seems
 
Not sure what format that is, but couldn't you do a preg_match_all? ie:
Code:
preg_match_all('/"[^"\r\n]*"/', 'a:2:{s:16:"authAmountString";s:10:"£33.39";s:11:"_SP_charEnc";s:5:"UTF-8";}', $matches);

Would return a multidimensional array though, but is a quick bodge....

Thanks but I am wondering should that work as-is? as it seems to not do anything. The syntax looks like it won't match up with the fields I have.

Thanks
 
OK thanks getting there, this is what I get out, but it's not a multidimensional array... I cannot address it using $matches[0][1] for example

Array ( [0] => Array ( [0] => "authAmountString" [1] => "£34.49"))

Thanks
 
Got it working now thanks, was being a n00b before :D

Thanks again for all the help!
 
Back
Top Bottom