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
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Post Select Data from Huge Array.

    Hello, I am implementing a WebMoney's X-Interface's script, that will return me the Balance of the Purse. Everything is working perfectly, but I do not know how to handle the Huge Array, Returned using the Interface. Please help me to get the data from the array I need.

    Here is the Response:

    Code:
    Array
    (
        [reqn] => 133640498580902
        [purses] => Array
            (
                [@attributes] => Array
                    (
                        [cnt] => 19
                        [wmid] => 899681838292
                    )
    
                [purse] => Array
                    (
                        [0] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 15948137
                                    )
    
                                [pursename] => Z381382653946
                                [amount] => 17.78
                                [desc] => WMZ privatais
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 695099593
                                [lastouttr] => 695800995
                            )
    
                        [1] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 15948141
                                    )
    
                                [pursename] => R763338134168
                                [amount] => 0
                                [desc] => WMR privatais
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 696106334
                                [lastouttr] => 696153435
                            )
    
                        [2] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 15948144
                                    )
    
                                [pursename] => E361153819205
                                [amount] => 0
                                [desc] => WME privatais
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 694460490
                                [lastouttr] => 694461100
                            )
    
                        [3] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 17006130
                                    )
    
                                [pursename] => U102414590724
                                [amount] => 0.02
                                [desc] => WMU privatais
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 365843422
                                [lastouttr] => 386390745
                            )
    
                        [4] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 18446845
                                    )
    
                                [pursename] => B228652187551
                                [amount] => 6.28
                                [desc] => WMB
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 597514989
                                [lastouttr] => 528874446
                            )
    
                        [5] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 18446853
                                    )
    
                                [pursename] => Y252266336617
                                [amount] => 0
                                [desc] => Array
                                    (
                                    )
    
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 198437882
                                [lastouttr] => 205454118
                            )
    
                        [6] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 18446856
                                    )
    
                                [pursename] => G404529273976
                                [amount] => 0
                                [desc] => WMG privatais
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 208117359
                                [lastouttr] => 214534986
                            )
    
                        [7] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 18446859
                                    )
    
                                [pursename] => D258476418853
                                [amount] => 272.11
                                [desc] => DEBIT
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 670267300
                                [lastouttr] => 684190707
                            )
    
                        [8] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 18446863
                                    )
    
                                [pursename] => C871673825005
                                [amount] => 0
                                [desc] => KREDIT
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 654376501
                                [lastouttr] => 649823946
                            )
    
                        [9] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328163
                                    )
    
                                [pursename] => Z224806191619
                                [amount] => 7941.07
                                [desc] => WMZ...auto
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 695498942
                                [lastouttr] => 695498025
                            )
    
                        [10] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328297
                                    )
    
                                [pursename] => R259456949262
                                [amount] => 50320.52
                                [desc] => WMR...auto
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 696153435
                                [lastouttr] => 695498958
                            )
    
                        [11] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328311
                                    )
    
                                [pursename] => E330862986454
                                [amount] => 233.97
                                [desc] => WME..auto
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 694461100
                                [lastouttr] => 692091130
                            )
    
                        [12] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328316
                                    )
    
                                [pursename] => U137080882513
                                [amount] => 7781.76
                                [desc] => WMU...auto
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 695498029
                                [lastouttr] => 694482468
                            )
    
                        [13] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328925
                                    )
    
                                [pursename] => Z308871843730
                                [amount] => 0
                                [desc] => WMZ...bank
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 690195842
                                [lastouttr] => 691252535
                            )
    
                        [14] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328934
                                    )
    
                                [pursename] => R406765386308
                                [amount] => 0
                                [desc] => WMR...bank
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 692444011
                                [lastouttr] => 693122697
                            )
    
                        [15] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328943
                                    )
    
                                [pursename] => E422435457360
                                [amount] => 0
                                [desc] => Array
                                    (
                                    )
    
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 662212063
                                [lastouttr] => 662212203
                            )
    
                        [16] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328950
                                    )
    
                                [pursename] => E315029676770
                                [amount] => 0
                                [desc] => WME...bank
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 681572487
                                [lastouttr] => 686873701
                            )
    
                        [17] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38328977
                                    )
    
                                [pursename] => G213287340600
                                [amount] => 0
                                [desc] => WMG...auto
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 0
                                [lastouttr] => 0
                            )
    
                        [18] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 38357208
                                    )
    
                                [pursename] => U117619792411
                                [amount] => 0
                                [desc] => WMU...bank
                                [outsideopen] => 1
                                [outsideopenstate] => 0
                                [lastintr] => 688268639
                                [lastouttr] => 688268772
                            )
    
                    )
    
            )
    
        [retval] => 0
        [retdesc] => Array
            (
            )
    
    )

    I need to pull the Account Balance for Every of the Purses, like Balance from "Z308871843730", Balance from "E315029676770", and like that..

    Thank you, Ralph.
    Last edited by WingTsun; 05-07-2012 at 05:00 PM.

  • #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
    Your examples don't match any data here. Closest match is under 'pursename'.
    PHP Code:
    foreach ($yourArray['purses']['purse'] AS $purse)
    {
        
    printf('purseName = %s' PHP_EOL$purse['pursename']);

    Should get that name.

  • Users who have thanked Fou-Lu for this post:

    WingTsun (05-07-2012)

  • #3
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Thank you for the Response, I still can not believe, that I could not understand, that I need to use "foreach" loop to get the data, since it is the standard solution. So thank you, this works perfectly, and can be closed.

    PHP Code:

    $X9 
    $res -> toArray();
            
    foreach (
    $X9['purses']['purse'] AS $purse) {

        echo 
    $purse['pursename'] . ' -> ' $purse['amount'] . '<br />';



  •  

    Posting Permissions

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