I'm trying to create a multidimensional array within a PHP function. But it doesn't seem to work. The function I wrote:
//Get newsitems
function getNews() {
$result = mysql_query("SELECT * FROM news WHERE archived='0' ORDER BY `id` DESC")
or die(mysql_error());
$array = array();
while($row = mysql_fetch_array($result)) {
$array[] = array ( 'title' => $row['title'],
'content' => $row['content'],
'date' => $row['pagid'],
'image' => $row['image'],
'youtube' => $row['youtube']
}
return $array;
}
Then I'm trying to get an array by doing this:
$aNews = getNews();
When I print this array nothing is showed. What am I doing wrong? The database query doesn't return any errors.