NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
help displaying results


Joined: 27 Aug 2008
Posts: 2
Reply with quote
I'm new to nusoap and have successfully connected to the server that is providing data to me. The data is returned into $result, but I don't know how to access the various elements of this array, and the structure is more complex than many of the examples that I've found, causing me a good deal of trouble.

How do I take the resulting arrays that follow and print out the content of the Category array in very simple form (for example as ID/Category/Description)? The following array is what is returned and printed out using print_r($result);

Any help is greatly appreciated.


Array
(
[getCreditCardCategoriesResult] => Array
(
[Categories] => Array
(
[Category] => Array
(
[0] => Array
(
[ID] => 0
[Category] => All
[Description] => All categories
)

[1] => Array
(
[ID] => 1
[Category] => Business
[Description] => Ideal for those who want to organize, consolidate, and easily manage business related expenses. Many business cards offer access to reward programs and unique benefits.
)

[2] => Array
(
[ID] => 21
[Category] => Canada
[Description] => Cards only available for those located in Canada.
)

[3] => Array
(
[ID] => 2
[Category] => Charge
[Description] => Ideal for those who are looking for credit cards with numerous cardholder benefits and prefer to pay their balance in full each month.
)

[4] => Array
(
[ID] => 5
[Category] => Poor Credit
[Description] => Ideal for those who have limited or damaged credit. Though numerous fees often apply for new cardholders, they do offer the opportunity to build or re-build credit.
)

[5] => Array
(
[ID] => 6
[Category] => Pre-Paid
[Description] => Designed for young adults who have yet to establish credit or for those who may have difficulty in obtaining a standard unsecured credit card.
)

[6] => Array
(
[ID] => 7
[Category] => Regular
[Description] => Our largest card category containing a variety of credit cards, most notably low interest rate credit cards.
)

[7] => Array
(
[ID] => 8
[Category] => Reward - Airline
[Description] => Ideal for frequent travelers, as airline reward cards allow cardholders to earn miles for every dollar spent, which can be redeemed for various travel related services and in most cases are compatible with their respective frequent flyer programs.
)

[8] => Array
(
[ID] => 10
[Category] => Reward - Cash
[Description] => Ideal for those who want to earn cash back for purchases made with their credit card and plan to pay in full each month.
)

[9] => Array
(
[ID] => 11
[Category] => Reward - Finance
[Description] => Designed for those who are looking for a reward program with financial related benefits.
)

[10] => Array
(
[ID] => 12
[Category] => Reward - Gas
[Description] => Ideal for those who want to earn rebates for every dollar spent on their card that can be applied for free gasoline.
)

[11] => Array
(
[ID] => 13
[Category] => Reward - Hotel
[Description] => Designed for those who frequently travel and would like to earn rewards that can be applied for free hotel stays and other unique benefits.
)

[12] => Array
(
[ID] => 14
[Category] => Reward - Other
[Description] => Cards that offer a unique reward program and do not fit in any of our standard reward sections are listed here. Those looking for something out of the ordinary may find this section appealing.
)

[13] => Array
(
[ID] => 15
[Category] => Reward - Retail
[Description] => Designed for those who want to earn points or rebates that can be applied towards retail purchases.
)

[14] => Array
(
[ID] => 16
[Category] => Reward - Sports
[Description] => Ideal for those who want to earn points or rebates that can be applied towards sport related items and services.
)

[15] => Array
(
[ID] => 17
[Category] => Reward - Travel
[Description] => Similar to that of airline reward cards and ideal for those who would are looking for alternative options in redeeming travel related rewards for every purchase made on the card.
)

[16] => Array
(
[ID] => 18
[Category] => Secured
[Description] => Unlike unsecured credit cards, secured credit cards require a deposit to open and secure the account, and are designed to help establish credit for those who may have limited or damaged credit.
)

[17] => Array
(
[ID] => 19
[Category] => Student
[Description] => These cards are solely designed for students in college and are ideal for those who are just starting to build credit. Some of the cards listed here may offer rewards and additional student related benefits.
)

)

)

[ServiceStatus] => Array
(
[TotalRowsReturnedByQuery] => 18
[RequestorAccountID] => XXXXXXXX
[ResponseCode] => 0
[ResponseDescription] => No errors
[FunctionName] => GetCreditCardCategories
)

)

)


Last edited by squambro on Sat Nov 08, 2008 10:51 am; edited 1 time in total
View user's profileFind all posts by squambroSend private message
think i figured it out


Joined: 27 Aug 2008
Posts: 2
Reply with quote
There's probably a better way to do it, but this seems to work:

$first = $result['getCreditCardCategoriesResult'];
$categories = $first['Categories'];
$items = $categories['Category'];

and then I can loop through $ items to print out each of the desired array elements:

foreach ($items as $i) {

<td><font size="-1"><b><? echo $i['Category']; ?></b><td><? echo $i['ID']; ?></td><td><? echo $i['Description']; ?>

}

I have the results printing out into a table just to see if they come out right, which they do. I'm new to PHP and brand new to nusoap, so I justed wanted to see if I could make it work and output data in usable form. Now that I've seen that I can do it, the wheels in my head are spinning. This is pretty cool.
View user's profileFind all posts by squambroSend private message
help displaying results
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic