Jump to content

unserialize array and display


php_begins

Recommended Posts

my user pm table has a touserarray field which is a serialized array that looks like this:

a:1:{s:2:"cc";a:1:{i:15773;s:14:"testusername";}}

i know I can unserialize it with the unserialize() function.

But I need to extract the value corresponding to 'i' field and the 's' field that has the username.

 

So  from the above array, i need to retrieve the value '15773' and 'testusername'.

Can someone tell me how?

 

 

Link to comment
https://forums.phpfreaks.com/topic/247955-unserialize-array-and-display/
Share on other sites

You didn't unserialize it because it is not valid.  Use:

error_reporting(E_ALL);
ini_set('display_errors', '1');

Because 'testusername' is length 12, it should be:

a:1:{s:2:"cc";a:1:{i:15773;s:12:"testusername";}}

Then you can use PFMaBiSmAd's method.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.