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
https://forums.phpfreaks.com/topic/34676-unserialize-variables/
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
https://forums.phpfreaks.com/topic/34676-unserialize-variables/#findComment-164223
Share on other sites

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.