Unserialize working on Windows but not Linux

Posted on 2006-04-07
Last Modified: 2012-05-05

I have a problem with the unserialize() function. On windows it is working fine but on linux it dosen't seem to work.

The string is just a series of timezones. This is the data:

a:27:{i:-11;s:40:"(GMT - 11:00 hours) Midway Island, Samoa";i:-12;s:40:"(GMT - 12:00 hours) Enitwetok, Kwajalien";i:-10;s:26:"(GMT - 10:00 hours) Hawaii";i:-9;s:25:"(GMT - 9:00 hours) Alaska";i:-8;s:45:"(GMT - 8:00 hours) Pacific Time (US & Canada)";i:-7;s:46:"(GMT - 7:00 hours) Mountain Time (US & Canada)";i:-6;s:45:"(GMT - 6:00 hours) Central Time (US & Canada)";i:-5;s:66:"(GMT - 5:00 hours) Eastern Time (US & Canada), Bogota, Lima, Quito";i:-4;s:58:"(GMT - 4:00 hours) Atlantic Time (Canada), Caracas, La Paz";s:4:"-3.5";s:37:"(GMT - 3:30 hours) Newfoundland (NST)";i:-3;s:65:"(GMT - 3:00 hours) Brazil, Buenos Aires, Georgetown, Falkland Is.";i:-2;s:57:"(GMT - 2:00 hours) Mid-Atlantic, Ascention Is., St Helena";i:-1;s:45:"(GMT - 1:00 hours) Azores, Cape Verde Islands";i:0;s:61:"(GMT) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia";i:1;s:68:"(GMT + 1:00 hours) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome";i:2;s:52:"(GMT + 2:00 hours) Kaliningrad, South Africa, Warsaw";i:3;s:51:"(GMT + 3:00 hours)Baghdad, Riyadh, Moscow, Nairobi";i:4;s:51:"(GMT + 4:00 hours) Adu Dhabi, Baku, Muscat, Tbilisi";i:5;s:61:"(GMT + 5:00 hours) Ekaterinburg, Islamabad, Karachi, Tashkent";i:6;s:42:"(GMT + 6:00 hours) Almaty, Colomba, Dhakra";i:7;s:42:"(GMT + 7:00 hours) Bangkok, Hanoi, Jakarta";i:8;s:63:"(GMT + 8:00 hours) Beijing, Hong Kong, Perth, Singapore, Taipei";i:9;s:56:"(GMT + 9:00 hours) Osaka, Sapporo, Seoul, Tokyo, Yakutsk";s:3:"9.5";s:26:"(GMT +9:30 hours) Adelaide";i:10;s:68:"(GMT + 10:00 hours) Melbourne, Papua New Guinea, Sydney, Vladivostok";i:11;s:59:"(GMT + 11:00 hours) Magadan, New Caledonia, Solomon Islands";i:12;s:63:"(GMT + 12:00 hours) Auckland, Wellington, Fiji, Marshall Island";}

Any ideas? On linux I get no array formed at all.
Question by:thepadders

    Author Comment

    Just to add, this data is stored in the database - it comes out as a result set that I then try to unserialize but it does not work.

    I am wondering if there is something wrong with the above or if there is a bug in unserialize().
    LVL 33

    Expert Comment

    Are the two servers using the same version of PHP?  What version is that?

    Author Comment


    The windows version is using PHP 5.1.1
    The linux server is using PHP 4.4.2

    But in the past people have mentioned the same problem on linux servers, but I am not sure with which other versions.
    LVL 33

    Expert Comment

    I'd try serializing the data on windows, then serializing the same data on linux, and compare the resulting strings.  Are they identical?

    Author Comment

    Seems the problem istn't with unserialize. The data is in XML and when I import it into a database on linux, for some reason the space after the closing bracket, ), just before Baghdad is lost. No idea why, very odd but that is what is breaking it.

    I had looked before to try and see a difference, but hadn't noticed that one bit of whitespace that was missing.

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to count occurrences of each item in an array.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now