Help us understand the problem. What is going on with this article?

配列、連想配列

More than 5 years have passed since last update.
配列空初期化、要素追加
$puni = array();
$puni[] = 'piti';
$puni[] = 'pitipiti';
print_r($puni);
//Array ( [0] => piti [1] => pitipiti )
連想配列空初期化、要素追加
$ary = array();
$ary['punipuni'] = 'puni';
$ary['pitipiti'] = 'piti';
print_r($ary);
//Array ( [punipuni] => puni [pitipiti] => piti )

配列、連想配列一緒の配列オブジェクト(?)に入れられるらしい。

キー存在チェック

存在チェック
if(isset($aray['キー値']))
または
if(array_key_exists('キー値',$aray))//キーがあったとしても、要素がNULLならfalseらしい。
KkssRe
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away