尝试添加更多数组项时收到错误

时间:2013-08-19 15:34:26

标签: php

我需要你的帮助。目前,我无法向此代码添加更多数组项;它给出了错误;我想不通,为什么?有人请帮帮我吗?否则,此代码工作正常。

<?php
function HTMLMenu($menu, $parentid = 0)
{
   $results = "";

   if (count($menu) > 0) {
   $results .= "<div id=\"recommended-links\">\n";
   $results .= "<p></p><ul>\n";
    $_menu = array_rand($menu, 4);
   foreach ($_menu as $item)
   {
        $results .= "<li>\n";
        $results .= "<img src='".$menu[$item]["img"]."' alt='' title='' class='imagecache' height='104' width='102'>\n";
        $results .= "<p>\n";
        $results .= "<a href='".$menu[$item]["url"]."'>".$menu[$item]["title"]."</a>\n";
        $results .= "</p>\n";
        $results .= "</li>\n";
   }
   $results .= "</ul>\n";
   $results .= "</div>\n";
   }

return $results;
}


$menu = array( 

'1' => array('id' => 1, 'parentid' => 0, 'title' => 'Nutritional Food With High Tyrosine',    'url' => '../../articles/artificial/nutritional_food_with_high_tyrosine.php', 'img' => '../../images/main_body_image/15_heart.jpg'), 
'2' => array('id' => 2, 'parentid' => 0, 'title' => 'Hair Loss & Rosemary Oil',   'url' => '../../articles/artificial/hair_loss_&_rosemary_oil.php',  'img' => 'http://photos.demandstudios.com/getty/article/178/201/87816905.jpg'), 
'3' => array('id' => 3, 'parentid' => 0, 'title' => 'Nutrition For Curved Down Finger Nails','url' => '../../articles/artificial/nutrition_for_curved_down_finger_nails.php',  'img' => '../../images/main_body_image/oo1.jpg'), 
'4' => array('id' => 4, 'parentid' => 3, 'title' => 'Nutrients That Aid in Heavy Metal Detox',     'url' => '../../articles/artificial/nutrients_that_aid_in_heavy_metal_detox.php',  'img' => '../../images/main_body_image/87716397.jpg'), 
'5' => array('id' => 5, 'parentid' => 4, 'title' => 'Does Taking Vitamin B12 Cause Weight Loss?',   'url' => '../../articles/artificial/does_taking_vitamin_b12_cause_weight_loss.php',  'img' => '../../images/main_body_image/87771685.jpg'), 
'6' => array('id' => 6, 'parentid' => 4, 'title' => 'What Fruit Cleans Out the Main Artery?', 'url' => '../../articles/artificial/what_fruit_cleans_out_the_main_artery.php',  'img' => '../../images/main_body_image/139572961.jpg'), 
'7' => array('id' => 7, 'parentid' => 4, 'title' => 'Can Food Enzyme Medication Make You Gain Weight?',     'url' => '../../articles/artificial/can_food_enzyme_medication_make_you_gain_weight.php',  'img' => '../../images/main_body_image/mood7.jpg'), 
'8' => array('id' => 8, 'parentid' => 3, 'title' => 'What Is Lecithin Used for in Dieting?',    'url' => '../../articles/artificial/what_is_lecithin_used_for_in_dieting.php',  'img' => '../../images/main_body_image/92838741.jpg'), 
'9' => array('id' => 9, 'parentid' => 3, 'title' => 'Raw Cacao & Weight Loss',    'url' => '../../articles/artificial/raw_cacao_&_weight_loss.php',  'img' => '../../images/main_body_image/87603913.jpg')
); 
?>

0 个答案:

没有答案