0
a:3:{ i:1; a:4:{
s:4:"time";s:1:"0";s:6:"points";s:1:"1";s:7:"correct";s:1:"1";
s:4:"data"; a:2:{i:0;s:1:"1";i:1;s:1:"0";} } i:2; a:4:{
s:4:"time";s:1:"0";s:6:"points";s:1:"0";s:7:"correct";s:1:"0";
s:4:"data"; a:1:{i:0;s:13:"kpk";} } s:4:"comp"; a:5:{
s:6:"points";s:1:"1";s:16:"correctQuestions";s:1:"1"; 
s:8:"quizTime";s:1:"9";s:6:"result";s:2:"50";s:4:"cats";
a:1:{i:0;s:2:"50";}} }

Hello everyone, I have a problem with above serialized array. I want to get the named 'data' array. Could you please advaise me how to get this?

3
  • Use unserialize on the string Commented May 14, 2014 at 7:46
  • Just unserialize it (us1.php.net/manual/en/function.unserialize.php) Commented May 14, 2014 at 7:47
  • Hello...json_decode and unserialize method doen't work. When i tried with this functions, it shows NULL. Please.. any advice? Commented May 14, 2014 at 8:00

1 Answer 1

2
$array=unserialize($serialized);
echo'<pre>';
print_r($array);
echo'</pre>';

You can then access the information like a normal array. For more information see: unserialize

Sign up to request clarification or add additional context in comments.

7 Comments

I get this array from database with this query function. $userdata = get_user_meta( $user_id, '_sfwd-data', true) and now i try to unserialize this. $array=unserialize($userdata); echo'<pre>'; print_r($array); echo'</pre>'; but it does not work. It shows nothing.
Please use var_dump($userdata) and show the output above.
Then $userdata does not deliver any result, I am not using Wordpress, so please ensure that your function call of "get_user_meta" is successful and provides data. If this is given, the unerialize will work out proper.
hello @D.Schalla, $userdata works without unserialize function. When i print out the result without serialize, it shows the serialized array.The problem is 'unserialize' i think.
Please use var_dump($userdata); directly under the $userdata=get_user_meta(...) and post the output. If this is false, it cannot work with unserialize. It should provide something different.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.