SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    unserialize not working

    Hi,

    I need to unserialize the following serialized array but it doesn't seem to work (just returns the same string).

    Any ideas?

    PHP Code:
    a:3:{i:1;s:7:"arsenal";i:2;s:9:"tottenham";i:3;s:7:"chelsea";} 

  2. #2
    SitePoint Enthusiast rajeev13's Avatar
    Join Date
    Nov 2012
    Location
    New Delhi,India
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zaggs View Post
    Hi,

    I need to unserialize the following serialized array but it doesn't seem to work (just returns the same string).

    Any ideas?

    PHP Code:
    a:3:{i:1;s:7:"arsenal";i:2;s:9:"tottenham";i:3;s:7:"chelsea";} 
    I have tested on my system worked fine :-
    $returnValue = unserialize('a:3:{i:1;s:7:"arsenal";i:2;s:9:"tottenham";i:3;s:7:"chelsea";} ');
    print_r($returnValue);


    output :
    Array ( [1] => arsenal [2] => tottenham [3] => chelsea )

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry the array should have been

    s:62:"a:3:{i:1;s:7:"arsenal";i:2;s:9:"tottenham";i:3;s:7:"chelsea";}";

    Does that work on your system as well?

  4. #4
    SitePoint Enthusiast rajeev13's Avatar
    Join Date
    Nov 2012
    Location
    New Delhi,India
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zaggs View Post
    Sorry the array should have been

    s:62:"a:3:{i:1;s:7:"arsenal";i:2;s:9:"tottenham";i:3;s:7:"chelsea";}";

    Does that work on your system as well?
    can you tell us which array is being serialize ,so you getting this string ..

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    51
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It looks to me that this is array serialized to string, and then again serialized to string, so try
    Code:
    unserialize(unserialize('s:62:"a:3:{i:1;s:7:"arsenal";i:2;s:9:"tottenham";i:3;s:7:"chelsea";}";'));


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •