質問: mysqli_fetch_array($result,MYSQLI_ASSOC) その$dataにcount($data)を実行しても、行の要素数14しか 表示されない。 echo count($data,COUNT_RECURSIVE); としても同じ。 $dataの中身を念のため、確認してみると以下の通り。Arrayごとに分かれてしまっているためか!? なぜ分かれるのかは不明です。 print_r($data); 【$dataの中身】 Array ( [access_type] => (102) [this] => 6 [one] => 44 [two] => 6 [three] => 0 [four] => 0 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 ) Array ( [access_type] => (201) [this] => 6 [one] => 40 [two] => 15 [three] => 0 [four] => 0 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 ) Array ( [access_type] => (103) [this] => 1 [one] => 22 [two] => 5 [three] => 0 [four] => 0 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 ) Array ( [access_type] => (301) [this] => 1 [one] => 8 [two] => 4 [three] => 5 [four] => 18 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 ) Array ( [access_type] => (202) [this] => 0 [one] => 16 [two] => 2 [three] => 0 [four] => 0 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 ) Array ( [access_type] => (203) [this] => 0 [one] => 12 [two] => 4 [three] => 0 [four] => 0 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 ) Array ( [access_type] => (204) [this] => 0 [one] => 1 [two] => 2 [three] => 0 [four] => 0 [five] => 0 [six] => 0 [seven] => 0 [eight] => 0 [nine] => 0 [ten] => 0 [eleven] => 0 [year] => 0 )
回答: ループでカウントするしかないですかね。。。 ``` $count = 0; foreach ($data as $datum) { $count += count($datum); } ``` count() の COUNT_RECURSIVE オプションは ``` array( 'one', 'two', 'three', array( 'apple', 'banana', 'melon' ) ); ``` のような配列の要素数をカウントするときに使用するものだったかと。