sdaspen Posted June 6, 2006 Share Posted June 6, 2006 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] => [email protected] [portal_id] => 286 [channel_id] => 761 [package_id] => 2252 [rating] => 2 ) ) [statuscode] => 1) Link to comment https://forums.phpfreaks.com/topic/11337-retrieving-array-value/ Share on other sites More sharing options...
Orio Posted June 6, 2006 Share Posted June 6, 2006 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. Link to comment https://forums.phpfreaks.com/topic/11337-retrieving-array-value/#findComment-42465 Share on other sites More sharing options...
Barand Posted June 6, 2006 Share Posted June 6, 2006 According to the output, it's an object[code]stdClass Object( [result] => Resource id #20 [numrows] => 1 [rows] => Array ( [0] => Array ( [id] => 32 [userid] => [email protected] [portal_id] => 286 [channel_id] => 761 [package_id] => 2252 [rating] => 2 ) ) [statuscode] => 1)[/code]so probably[code]$rating = $uroutput->rows[0]['rating'];[/code] Link to comment https://forums.phpfreaks.com/topic/11337-retrieving-array-value/#findComment-42640 Share on other sites More sharing options...
sdaspen Posted June 7, 2006 Author Share Posted June 7, 2006 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] Link to comment https://forums.phpfreaks.com/topic/11337-retrieving-array-value/#findComment-42687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.