Jump to content

Unserialize variables?


AnotherPoetsCry

Recommended Posts

I have a list of variables that the users enter. i then serialize this list and save this to a table. can i unserialize this and get the variables back just as they were before i serialized them? for example $sellerLabel can still be called $sellerLabel after unserialization?

[code]

$options = serialize( $this->globalsInfo['options'] = array( 'notReady' => $this->globalsInfo['notReady'], 'sellerLabel' => $sellerLabel, 'minP' => $minP, 'minPName' => $minPName, 'maxP' => $maxP, 'maxPName' => $maxPName, 'buyerLabel' => $buyerLabel, 'minQ' => $minQ, 'minQName' => $minQName, 'demand' => $demand, 'demandName' => $demandName, 'value' => $value, 'valueBuyersName' => $valueBuyersName, 'valueSellersName' => $valueSellersName, 'cost' => $cost, 'costBuyersName' => $costBuyersName, 'costSellersName' => $costSellersName, 'prob' => $prob, 'probName' => $probName, 'forceFix' => $forceFix, 'displayAllProfits' => $displayAllProfits, 'test' => $test, 'testDelay' => $testDelay ) );
       
[/code]

[code]
$this->globalsInfo['options'] = unserialize( $this->globalsInfo['options'] );
foreach( $this->globalsInfo['options'] as $key => $value )
$this->$key = $value;
[/code]
Link to comment
Share on other sites

PHP question not a MySQL question, mysql is just storing it as text.

But to answer your question, no. Serialize only stores the value of the variable. So to restore it to the same name you would have to also store the name in a variable before you serialize it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.