i want to unserialize? and display Array from my text field in db table.

This is what i use to serialize on Insert statement.

$persons = serialize(array($paymentData['anArray']));

and this returns after var_dump

["persons"]=> string(104) "a:1:{i:0;a:2:{i:0;a:1:{s:5:"value";s:15:"Producer: Simon";}i:1;a:1:{s:5:"value";s:13:"Writer: Simon";}}}"

Now the object that i return from Select statement is memberDetails

$sql = "SELECT *
FROM memberDetails M WHERE M.id=:id";
$db = getDB();
$stmt = $db->prepare($sql);
$stmt->bindParam("id", $id, PDO::PARAM_INT);
$stmt->execute();
$memberDetails = $stmt->fetch(PDO::FETCH_OBJ);
var_dump ($memberDetails); exit;
$response['success'] = true;
$response['memberDetails'] = $memberDetails;

echo json_encode($response);

So i want to return two values and display them: like this

Writer: Simon and Producer:Simon

Any help?

Recommended Answers

All 2 Replies

Sorry, I'm confused by your question. The same way you use serialize() you can use unserialize().

What happens if you do var_dump(unserialize($memberDetails));?

commented: i am getting bool(false) +5

If you’re getting unserialize() to return false, it’s because the string being passed in is not a valid PHP serialized string.

Confirm that your MySQL query is correct and fetches the column that contains the serialized string.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.