LoginSignup
1
0

More than 3 years have passed since last update.

【PHP】キーを指定して配列に要素を追加したい

Last updated at Posted at 2018-06-04

やりたいこと

配列にキーを指定した要素を追加したい

「$f["key"] = value;」でキーを指定して追加できる

$f = ["a" => "りんご", "m" => "みかん", "b" => "ばなな"];
$f["p"] = "パイナップル";
print_r($f);

実行結果
Array ( [a] => りんご [m] => みかん [b] => ばなな [p] => もも )

う~ん便利

1
0
0

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