PHP.unserialize's strange behaviour

M

Milo Thurston

I have some code that needs to obtain information from a web service in
the form of an array of values to be plotted as a graph. The data I need
come back in the form of a string, as seen at
http://users.ox.ac.uk/~lina0989/string.txt. So, the plan is to get at
the data using this code:
http://www.aagh.net/files/ruby/php_serialize.rb

If I run PHP.unserialize(string) then I get an array of nil values.
However,
PHP.serialize(PHP.unserialize(string)), or any equivalent, returns the
same string I started off with. Has anyone got any idea as to what would
cause this odd outcome?
 
T

Thomas Hurst

* Milo Thurston ([email protected]) said:
I have some code that needs to obtain information from a web service
in the form of an array of values to be plotted as a graph. The data I
need come back in the form of a string, as seen at
http://users.ox.ac.uk/~lina0989/string.txt. So, the plan is to get at
the data using this code:
http://www.aagh.net/files/ruby/php_serialize.rb

If I run PHP.unserialize(string) then I get an array of nil values.
However, PHP.serialize(PHP.unserialize(string)), or any equivalent,
returns the same string I started off with. Has anyone got any idea as
to what would cause this odd outcome?

How is it odd? You get the same thing unserializing in PHP.

Your string.txt: a:1920:{i:0;N;i:1;N;i:2;N; ... ;i:1918;N;i:1919;N;}

Read as: Array, 1920 elements, comprised of: integer key 0, NULL value,
integer key 1, NULL value, integer key 2, NULL value...
 
M

Milo Thurston

Thomas said:
How is it odd?

Unfortunately for me it seemed odd because I cocked up and was causing a
different string to be passed to my PHP and Ruby scripts without
noticing the difference.
Looking silly therefore serves me right, I suppose. :$
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top