Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Is this an object? How to covert it?

    I am working the myWOT API response code. What I get from their server seems to be an Object, rather then an Array.

    What I want to get is: 83 - 86 - 88 - 86

    How can I get there?

    PHP Code:
    string(106"{ "foxnews.com": 

                            { "
    target": "foxnews.com", 
                            
                            "
    0": [ 83, 57 ], 
                            "
    1": [ 86, 61 ], 
                            "
    2": [ 88, 65 ], 
                            "
    4": [ 86, 62 ] 
                            
                            } 
                }" 
    Update: I didn't solve object issue at all, but found out the myWOT also has a XML output which makes things much easier.
    Last edited by fail; 02-11-2013 at 10:38 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    XML is a lot easier to work with, so stick with that.
    That is neither an object nor an array. That is a string. You can decode that using json_decode() function which will return an object.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,213
    Thanks
    12
    Thanked 338 Times in 334 Posts
    Quote Originally Posted by Fou-Lu View Post
    You can decode that using json_decode() function which will return an object.
    or an array, if you tell json_decode() to generate one instead of an object.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

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