Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
idsデータベース テーブルに格納されている一部のレコードに固有の数値の文字列を含む変数があります。文字列値は次のようになります。関数を"3,4,4,6,2,4,7,7,7"使用explode()してこれらの数値を配列に変換し、ループを使用して識別されるレコードを取得できるようにします。以前はarray_unique()繰り返し発生する数字を削除していましたが、文字列内で特定の数字が何回発生したかを知る方法が必要です。どうすればそれができますか?ありがとうございました。
ids
"3,4,4,6,2,4,7,7,7"
explode()
array_unique()
使用する:
array_count_values($array)
それはあなたに与える
Array ( [3] => 1 [4] => 3 [6] => 1 [2] => 1 [7] => 3 )