LoginSignup
1
0

More than 3 years have passed since last update.

[PHP] 配列のキーだけを取得する

Posted at

概要

配列のキーを一覧を取得する方法をメモします。

方法

  • array_keys()を利用する
  • 第一引数にarrayを指定
<?php
$array1 = [
    'a' => 1,
    'b' => 2,
    'c' => 3
];

$result = array_keys($array1);

print_r($result);
?>

結果

Array
(
    [0] => a
    [1] => b
    [2] => c
)
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