Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:13:47+00:00 2026-06-10T04:13:47+00:00

AHow can I take the below array, coming from a webservice’s XML output, and

  • 0

AHow can I take the below array, coming from a webservice’s XML output, and pull out the [Key]s and their [Value]s and turn them into PHP variables (key matching its value) so I can use them for within PHP scripts. Not having any luck with it, done some research and I am not seeing this layout anywhere. This layout just looks different and I can’t find any examples of this particular layout conversion. Is there a way to pull out specific string data from below such as “user.id” and assign it its value “431349” as php variables ?

Array
(
    [RedeemTokenResult] => Array
        (
            [DictionaryEntry] => Array
                (
                    [0] => Array
                        (
                            [Key] => environmentname
                            [Value] => Staging
                        )

                    [1] => Array
                        (
                            [Key] => user.prc.type
                            [Value] => C
                        )

                    [2] => Array
                        (
                            [Key] => user.country
                            [Value] => United States
                        )

                    [3] => Array
                        (
                            [Key] => user.displayname
                            [Value] => Corporate User
                        )

                    [4] => Array
                        (
                            [Key] => sso.testmode
                            [Value] => True
                        )

                    [5] => Array
                        (
                            [Key] => user.region
                            [Value] => Texas
                        )

                    [6] => Array
                        (
                            [Key] => user.par.seg.id
                            [Value] => 1
                        )

                    [7] => Array
                        (
                            [Key] => user.postalcode
                            [Value] => 10001
                        )

                    [8] => Array
                        (
                            [Key] => session.expire.timeout
                            [Value] => 60
                        )

                    [9] => Array
                        (
                            [Key] => user.lastname
                            [Value] => User
                        )

                    [10] => Array
                        (
                            [Key] => user.par.classoftrade
                            [Value] => ALL
                        )

                    [11] => Array
                        (
                            [Key] => user.id
                            [Value] => 431349
                        )

                    [12] => Array
                        (
                            [Key] => user.firstname
                            [Value] => Corporate
                        )

                    [13] => Array
                        (
                            [Key] => user.par.id
                            [Value] => 0
                        )

                    [14] => Array
                        (
                            [Key] => user.city
                            [Value] => test
                        )

                    [15] => Array
                        (
                            [Key] => user.address1
                            [Value] => test
                        )

                    [16] => Array
                        (
                            [Key] => user.profile.companyname
                            [Value] => TradeOne
                        )

                    [17] => Array
                        (
                            [Key] => user.email
                            [Value] => nickk@tradeonemktg.com
                        )

                    [18] => Array
                        (
                            [Key] => user.username
                            [Value] => tomsnac
                        )

                    [19] => Array
                        (
                            [Key] => sso.client.hostname
                            [Value] => 10.1.2.135
                        )

                    [20] => Array
                        (
                            [Key] => session.expire.url
                            [Value] => https://ssostage.tradeonemktg.com/ReturnUrl=https%3a%2f%2fprcstage3.tradeonemktg.com%2fv%2f6%2f1%2fprc%2fsn%2fLogin.aspx%3freturnurl%3d%252fv%252f6%252f1%252fprc%252fsn%252fHome.aspx
                       )

                    [21] => Array
                        (
                            [Key] => sso.client.ip4
                            [Value] => 10.1.2.135
                        )

                    [22] => Array
                        (
                            [Key] => user.timezone
                            [Value] => (GMT-06:00) Central Time (US & Canada)
                        )

                    [23] => Array
                        (
                            [Key] => user.culture
                            [Value] => en-US
                        )

                    [24] => Array
                        (
                            [Key] => user.par.seg.marketcode
                            [Value] => NDC
                        )

                    [25] => Array
                        (
                            [Key] => user.telephone
                            [Value] => 111111111
                        )

                    [26] => Array
                        (
                            [Key] => session.expire.time
                            [Value] => 7/23/2012 12:38:28 PM
                        )

                    [27] => Array
                        (
                            [Key] => sso.xfer.parameters
                            [Value] => 
                        )

                    [28] => Array
                        (
                            [Key] => sso.timestamp
                            [Value] => 7/23/2012 11:38:31 AM
                        )

                )

        )

)

========================
THIS IS THE PHP FILE I AM WORKING ON ….

<?
require_once "SSO.class.php";

$service = 'https://XXX.XXX.XXX.com/SSO/XXXXXX.asmx'; //Service URl from TradeOne
$affiliate = 'XXXXXXXXXXXXXXXXXXXXXXX'; // Affiliate from TradeOne
$pass = XXXXXXXXXXXXXXXXXXXXXXX; //Password secret from TradeOne

$token = $_REQUEST['token'];

$sso = new SSO($pass);
$hashedToken = $sso->encryptToken($token,$salt,$iv);

print $sso->toString();

require_once "../soap_lib/nusoap.php";
$client   = new nusoap_client($service.'?WSDL',true);
$tok = array(
             'affiliate'=>$affiliate,
             'hashedToken'=>$hashedToken
             );

$response = $client->call('RedeemToken',array('parameters'=>$tok)); 

echo '<br /><br />';

function keyValue(&$response) {
  $result = Array();
  foreach($response as $row) {
    $result[$row['Key']] = $row['Value'];
  }
  $a = $result;
}

keyValue($a['RedeemTokenResult']['DictionaryEntry']);



var_dump($response);

?>

This is the last edit I did and resulted in:

Warning: Invalid argument supplied for foreach() in /xxxx/xxxx/xx/xxxx/xxxx/xxx/xxxxxx.php on line 51
array(1) { [“RedeemTokenResult”]=> array(1) { [“DictionaryEntry”]=> NULL } }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:13:48+00:00Added an answer on June 10, 2026 at 4:13 am

    You should use an array instead of trying to create a bunch of variables. You can create a dynamic, multidimensional array like this:

    $result = array();
    foreach( $response['RedeemTokenResult']['DictionaryEntry'] as $item) {
        $keys = explode( '.', $item['Key']);
        $array_name = array_shift( $keys); // Get name of the array
        $temp =& $result[$array_name];
        foreach( $keys as $key)
        {           
            $temp =& $temp[$key];
        }
        $temp = trim( $item['Value']);
    }
    

    This produces a single $result array that looks like:

    Array
    (
        [user] => Array
            (
                [telephone] => 111111111
            )
    
        [session] => Array
            (
                [expire] => Array
                    (
                        [time] => 7/23/2012 12:38:28 PM
                    )
    
            )
    
        [sso] => Array
            (
                [xfer] => Array
                    (
                        [parameters] => 
                    )
    
            )
    
    )
    

    Now you can grab elements like:

    echo $result['user']['telephone'];
    echo $result['session']['expire']['time'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a = ['cat','dog'] random.choice(a) How can I choose a random word, and pull out
Please take a look at the picture below. When we create an object in
Possible Duplicate: strange output in comparision of float with float literal I can't understand
I'm getting strange characters when pulling data from a website: Â How can I
I have a PHP Array, and I want to extract from it the duplicated
I've made a quick python script that converts to Unicode from ASCII and back.
A) How can I set scroll to always appear on x and Y acies
For an assesment in C i have to take two files with strings within
I have a particular data manipulation requirement that I have worked out how to
A comment to another of my questions says that I can only run so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.