|
Posted by Kimmo Laine on 01/16/07 07:10
"Sanders Kaufman" <bucky@kaufman.net> wrote in message
news:otSqh.20353$yC5.3398@newssvr27.news.prodigy.net...
> Toby Inkster wrote:
>> Sanders Kaufman wrote:
>>
>>> You could use the "explode" and "compress" array functions in PHP.
>>
>> serialize() and unserialize() would probably be better choices.
>
>
> I thought those were the same thing.
> What's the difference?
$original = array('foo'=>'bar;zap');
print_r($original);
print_r(unserialize(serialize($original)));
print_r(explode(';', implode(';', $original)));
Differences when using explode/implode:
- keys are lost
- if a string value happens to have the split/glue character, it totally
messes up the array
serialize/unserialize preserves the array structure better. Implode and
explode aren't completely useless, on a special occasion they work just
fine, still serialize/unserialize is more stable solution.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|