1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPの連想配列について(Progate)

Posted at

##学習コース
Progate
PHP 道場コース Ⅰ → 連想配列の操作をマスターしよう9. → 全ての価格を表示しよう

##ソースコード

<?php
$menus = array(
  array('name' => 'CURRY', 'price' => 900),
  array('name' => 'PASTA', 'price' => 1200),
  array('name' => 'COFFEE', 'price' => 600)
);

// この下にコードを書いてください
foreach ($menus as $menu) {
  echo $menu['name']."は".$menu['price']."円です";
  echo '<br>';
}

?>

---出力結果---
CURRYは900円です
PASTAは1200円です
COFFEEは600円です

##質問内容

  foreach ($menus as $menu) { ~~~~}

↑foreach内にあるこの[$menu]はどこからきたのでしょうか? [$menus]は最初に定義されているのでわかるのですが。 例えばここが[$prices]なら[$price]といったように 単純に複数形「s」を取ったものになるのでしょうか?

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?