配列の値の数を数える
<?php $array = array( "投資家1" => "強く買いたい", "投資家2" => "売りたい", "投資家3" => "強く買いたい", "投資家4" => "買いたい", "投資家5" => "様子見", "投資家6" => "買いたい", "投資家7" => "買いたい", "投資家8" => "買いたい" ); $board = array_count_values($array); arsort($board); var_dump($board);
array(4) { [“買いたい”]=> int(4) [“強く買いたい”]=> int(2) [“様子見”]=> int(1) [“売りたい”]=> int(1) }