I have a function that retrieves data from a Mysql database, stores the values in an array and returns that array to the calling function.
$stmt = $dbh->prepare("SELECT img_file_name FROM mjbox_images JOIN mjbox_posts USING (post_id) WHERE post_active = 0 AND post_id = ? ");
$stmt->bindParam(1,$post_id);
$stmt->execute();
$resultarray = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$resultarray[] = $row;
}
return $resultarray;
I am attempting to echo out the $values within that array like this:
$resultarray = get_post_data($post_id);
print_r($resultarray);
foreach($resultarray as $key => $value){
echo 'The value is: '. $value . '<br />';
}
But when I browse the webpage it is only echoing out "Array". When I print_r the array the values are definitely in the array. So how do I correctly display those values?