1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to Show result from JSON

Discussion in 'PHP' started by rahu_l_, Mar 1, 2015.

  1. #1
    Hello DP,

    i need a help ..
    i have a code which give json out put when :

    print_r(json_decode($result, true));

    the result code as :

    Array
    (
        [USER_INFORMATION] => Array
            (
                [REGISTER_ID] => 30772000
                [EXPIRED] => 0
                [PAYING_USER] => 1
                [SERVICE_COUNTRY_NAME] => India-Other
                [AD_SUPPORT] => 0
                [IS_PREMIUM] => 0
                [IS_TRUE_NAME] => 1
                [IS_AMBASSADOR] => 0
            )
    
        [PREMIUM] => Array
            (
                [IS_PREMIUM] => 0
                [EXPIRES] =>
                [CONTACTS] => 0
                [TRANSACTION_ID] => Array
                    (
                    )
    
            )
    
        [user_account] => Array
            (
                [account_status] => verified
                [credits] => 0
                [price] => 150
            )
    
        [device_account] => Array
            (
                [registerid] => 30772000
                [device_status] => verified
                [enhanced_search_status] => 1
            )
    
        [SEARCH_RESULT] => Array
            (
                [PAGE] => 1
                [END_PAGE] => 1
                [TOTAL] => 1
                [FOUND_UGC_RESULT] => 0
                [SR] => Array
                    (
                        [@attributes] => Array
                            (
                                [id] => 0
                            )
    
                        [NAME] => Rahul
                        [TEL_00] => 917540851107
                        [NATIONAL_NUMBER] => 075408 51107
                        [NUMBER] => +917540851107
                        [NUMBER_TYPE] => 1
                        [ADDRESS] => Bamori, Madhya Pradesh
                        [STREET] =>
                        [ZIPCODE] =>
                        [AREA] => Bamori, Madhya Pradesh
                        [COUNTRY] => India
                        [LINK1] =>
                        [MAP_URL] =>
                        [COUNTRY_CODE] => 91
                        [COUNTRY_CODE_NAME] => IN
                        [PHOTO_URL] =>
                        [PHOTO_LARGE_URL] =>
                        [MESSAGE] =>
                        [PARSED_ADDRESS] =>
                        [SPAM_SCORE] =>
                        [SPAM_TYPE] =>
                        [OPERATOR] =>
                        [POPULARITY_SCORE] =>
                        [ACCESS] => public
                        [PRIVATE_ID] => 2svf1WaSG1t2/H1nw==
                        [CONFIDENCE] => 31
                        [AUTO_ACCEPT] => 2
                        [RATE] =>
                        [background_id] =>
                        [PHONES_CONNECTING] =>
                        [USERS_CONNECTING] =>
                        [STATUS_MESSAGE] =>
                        [FACEBOOK_ID] =>
                        [EMAIL_ID] =>
                        [TWITTER_ID] =>
                        [TWITTER_NAME] =>
                        [TWITTER_SCREEN_NAME] =>
                        [TWITTER_PHOTO_URL] =>
                        [PARTNER_LOGO] =>
                        [IS_PREMIUM] => 0
                        [IS_TRUE_NAME] => 0
                        [IS_AMBASSADOR] => 0
                        [IS_USER] => 0
                        [JOB_TITLE] =>
                        [COMPANY_NAME] =>
                        [IS_UNLISTED] => Array
                            (
                            )
    
                    )
    
            )
    
    )
    PHP:
    i need the output as :

    Name: Rahul
    Number:917540851107
    Country: India

    How to do it :(
     
    Solved! View solution.
    rahu_l_, Mar 1, 2015 IP
  2. #2
    Create a variable:
    
    $result = json_decode($result,true);
    
    Code (markup):
    and then just do
    
    echo 'Name: '.$result['SEARCH_RESULT']['SR']['NAME'].'<br>Number: '.$result['SEARCH_RESULT']['SR']['TEL_00'].'<br>Country: '.$result['SEARCH_RESULT']['SR']['COUNTRY'];
    
    PHP:
    The correct way would be to do this as a list, or similar, but the above will work.
     
    PoPSiCLe, Mar 3, 2015 IP
    rahu_l_ likes this.
  3. rahu_l_

    rahu_l_ Well-Known Member

    Messages:
    525
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Thank You! :)
     
    rahu_l_, Mar 3, 2015 IP