Name: Anonymous 2008-03-28 16:39
I'm a code noob, so I'm teaching myself different concepts that I may need. I'm using PHP because it's easy. Today I was working on serialization... rendering live data in ram into a string so that it can be transmitted or stored statically.
I happened across some sillyness while dealing with a floating point number:
Code:
<?php
$ar["four"] = "chan";
$ar["foo"] = array("bar" => "foobar");
$ar["bob"] = "bob";
$ar["spleen"] = 199;
$ar[5] = 1.222;
$serialar = serialize($ar);
echo "$serialar\n";
$unserializedar = unserialize($serialar);
print_r ($unserializedar);
?>
output:
a:5:{s:4:"four";s:4:"chan";s:3:"foo";a:1:{s:3:"bar";s:6:"foobar";}s:3:"bob";s:3:
"bob";s:6:"spleen";i:199;i:5;d:1.22199999999999997513100424839649349451065063476
5625;}
Array
(
[four] => chan
[foo] => Array
(
[bar] => foobar
)
[bob] => bob
[spleen] => 199
[5] => 1.222
)
I happened across some sillyness while dealing with a floating point number:
Code:
<?php
$ar["four"] = "chan";
$ar["foo"] = array("bar" => "foobar");
$ar["bob"] = "bob";
$ar["spleen"] = 199;
$ar[5] = 1.222;
$serialar = serialize($ar);
echo "$serialar\n";
$unserializedar = unserialize($serialar);
print_r ($unserializedar);
?>
output:
a:5:{s:4:"four";s:4:"chan";s:3:"foo";a:1:{s:3:"bar";s:6:"foobar";}s:3:"bob";s:3:
"bob";s:6:"spleen";i:199;i:5;d:1.22199999999999997513100424839649349451065063476
5625;}
Array
(
[four] => chan
[foo] => Array
(
[bar] => foobar
)
[bob] => bob
[spleen] => 199
[5] => 1.222
)