3
6

【PHP】配列の1つ目のデータを取りたい

Last updated at Posted at 2023-07-27

配列の中に値が1つ目の値を取得したい時どうしていますか?

配列の添え字

echo $items[0];

Reset関数

echo reset($items);

current関数

echo current($items);

ループ処理

正直する人いるのか不明ですが...

foreach($items as $item) {
  echo $item;
  continue;
}
3
6
1

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
3
6