How do I get data from a nested array returned by $wpdb?
-
Hi all, so I’m trying to do something like this…
$theResult=array();
$theUserNames=array();$results = $wpdb->get_results(“SELECT * FROM firstTable WHERE user_num=16”);
foreach($results as $row){
$theResult[]=$row->id;
}
foreach($theResult as $newId)
{$userNames = $wpdb->get_results($wpdb->prepare(“SELECT userInfo FROM secontTable WHERE ID=%d LIMIT 1”,$newId));
$theUserNames[]=$userNames;
}
print_r($theUserNames);This seems to get the data but I have trouble unwrapping it. The result looks something like this:
Array ( [0] => Array ( [0] => stdClass Object ( [userInfo] => theDataThatIWant ) ) ).
How do I get just theDataThatIWant and put them in an unnested array?
The topic ‘How do I get data from a nested array returned by $wpdb?’ is closed to new replies.