Jump to content

Archived

This topic is now archived and is closed to further replies.

sdaspen

Retrieving array value

Recommended Posts

I have an array that I can view if i print_r($uroutput) (see results below).
How do I grab the [rating] value of 2 to be displayed elsewhere on the page.

Thanks,



stdClass Object
(
[result] => Resource id #20
[numrows] => 1
[rows] => Array
(
[0] => Array
(
[id] => 32
[userid] => sdaspen32@aol.com
[portal_id] => 286
[channel_id] => 761
[package_id] => 2252
[rating] => 2
)

)

[statuscode] => 1
)

Share this post


Link to post
Share on other sites
I am not sure, but I believe "echo($urooutput[0][rating]);" Will do the job :) (It's a nested Array, right?)


But if it's a mysql result, use:

[code]$output=mysql_result($uroutput,"0","rating");
echo($output);[/code]

Orio.

Share this post


Link to post
Share on other sites
According to the output, it's an object

[code]stdClass Object
(
    [result] => Resource id #20
    [numrows] => 1
    [rows] => Array
    (
        [0] => Array
        (
            [id] => 32
            [userid] => sdaspen32@aol.com
            [portal_id] => 286
            [channel_id] => 761
            [package_id] => 2252
            [rating] => 2
        )

    )

    [statuscode] => 1
)[/code]

so probably

[code]$rating = $uroutput->rows[0]['rating'];[/code]

Share this post


Link to post
Share on other sites
Thanks Orio and Barand for your quick responses. I greatly appreciate it. Barand your solution was the one that solved it for me. Thanks again.



so probably

[code]$rating = $uroutput->rows[0]['rating'];[/code]
[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.