私はプロジェクトの小売サイトを作成しています。連想配列を画像として割り当てる方法php
アレイで実際の小売店のウェブサイトのように画像が表示されるようにするにはどうすればよいですか?たとえば、行の後の行にきれいに4つの画像があります。
<?php
$navItems = array (
array(
'slug' => "index.php",
'title' => "Home"
),
array(
'slug' => "menu.php",
'title' => "Menu"
),
array(
'slug' => "contact.php",
'title' => "Contact"
),
);
$menuItems = array(
"club-sandwich" => array(
"name" => "Club Sandwich",
"price" => 11,
"blurb" => "Bacon ipsum dolor sit amet fatback landjaeger ullamco pariatur. Nostrud laboris et, duis drumstick eiusmod kevin ut aliquip. Filet mignon short ribs tenderloin short loin kielbasa non pork chop aliqua. Jerky shank tri-tip capicola, non andouille tenderloin cupidatat turducken meatball pork beef eu shoulder jowl.",
"drink" => "Club Soda"
),
"dill-salmon" => array(
"name" => "Lemon & Dill Salmon",
"price" => 18,
"blurb" => "Pork belly tempor ground round qui exercitation, jowl leberkas sed voluptate excepteur jerky. Reprehenderit veniam cow, quis in ribeye andouille eu pastrami eiusmod exercitation dolor.",
"drink" => "Fancy Wine"
),
"super-salad" => array(
"name" => "The Super Salad<sup>®</sup>",
"price" => 34,
"blurb" => "Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.",
"drink" => "Jug o' Water"
),
"mexican-barbacoa" => array(
"name" => "Mexican Barbacoa",
"price" => 23,
"blurb" => "I love fruitcake danish caramels. Tart danish pastry liquorice chocolate cake fruitcake. Bear claw gingerbread muffin I love apple pie apple pie tiramisu brownie chocolate. Sweet roll cotton candy cupcake gingerbread gummies jelly-o. Muffin I love croissant I love jelly-o brownie jelly beans. Toffee I love pastry.",
"drink" => "Beer with a lime"
),
);
?>
イメージを配列の一部として割り当てると思ったが、機能しなかった。
<?php
$navItems = array (
array(
'slug' => "index.php",
'title' => "Home"
),
array(
'slug' => "menu.php",
'title' => "Menu"
),
array(
'slug' => "contact.php",
'title' => "Contact"
),
);
$menuItems = array(
"club-sandwich" => array(
"name" => "Club Sandwich",
"price" => 11,
"blurb" => "Bacon iort loin kielbasa non pork chop aliqua. Jerky shank tri-tip capicola, non andouille tenderloin cupidatat turducken meatball pork beef eu shoulder jowl.",
"drink" => "Club Soda"
"image" => <img src="hr.png">
),
"dill-salmon" => array(
"name" => "Lemon & Dill Salmon",
"price" => 18,
"blurb" => "Pork belly tempor ground round qui exercitation, jowl leberkas sed voluptate excepteur jerky. Reprehenderit veniam cow, quis in ribeye andouille eu pastrami eiusmod exercitation dolor.",
"drink" => "Fancy Wine"
"image" => <img src = "hr.png">
),
"super-salad" => array(
"name" => "The Super Salad<sup>®</sup>",
"price" => 34,
"blurb" => "Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.",
"drink" => "Jug o' Water"
"image" => <img src = "hr.png">
),
"mexican-barbacoa" => array(
"name" => "Mexican Barbacoa",
"price" => 23,
"blurb" => "I love fruitcake danish caramels. Tart danish pastry liquorice chocolate cake fruitcake. Bear claw gingerbread muffin I love apple pie apple pie tiramisu brownie chocolate. Sweet roll cotton candy cupcake gingerbread gummies jelly-o. Muffin I love croissant I love jelly-o brownie jelly beans. Toffee I love pastry.",
"drink" => "Beer with a lime"
"image" => <img src = "hr.png">
),
);
?>
'" image "=>'は有効なPHP構文ではありません。配列をレンダリングするときにURIを送信し、 ''タグを生成するだけです: '' image "=>" hr.png "'、 '' ' –
jpec
ああ、代わりに私のフォルダから画像を取得する方法はありますか? – Jinn
申し訳ありませんが、私はあなたの質問を理解していません。 – jpec