0
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 3 years have passed since last update.

配列の値を集計する

Posted at

学習記録

#前提条件
・PHP version 5.4

#配列のソートとシャッフル

##array_fill
配列を作る

書式
array_fill(最初のインデックス, 要素の数, 要素の値)
built.php
$scores = array_fill(0, 5, 10);
print_r($scores);
//Array(
//  [0] => 10
//  [1] => 10
//  [2] => 10
//  [3] => 10
//  [4] => 10)

##range
ある範囲の整数を有する配列を作成する

書式
range(最初の値, 終わりの値)
built.php
$scores = range(1, 5);
print_r($scores);
//Array(
//  [0] => 1
//  [1] => 2
//  [2] => 3
//  [3] => 4
//  [4] => 5)

//第三引数に数字を入れるとその数字分増加する
$scores = range(1, 10, 2);
print_r($scores);
//Array(
//  [0] => 1
//  [1] => 3
//  [2] => 5
//  [3] => 7
//  [4] => 9)
関数 概要         
max()           配列の要素の最大値
min()           配列の要素の最小値
array_sum()      配列の要素の合計
conut()        配列の要素の数
0
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
0
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?