私は以下のコードを使用していますが、出力が必要です。例外出力例特定のJSON形式のPHParray
<?php
$text = "A very nice únÌcÕdë text. Something nice to think Something about if you're into Unicode.";
$words = str_word_count($text, 1); // use this function if you only want ASCII
$frequency = array_count_values($words);
arsort($frequency);
print_r($frequency);
?>
**Current output**
Array
(
[nice] => 2
[Something] => 2
[A] => 1
[very] => 1
[n] => 1
[c] => 1
[d] => 1
[text] => 1
[to] => 1
[think] => 1
[about] => 1
[if] => 1
[you're] => 1
[into] => 1
[Unicode] => 1
)
**Excepted output Below :**
{
{
‘word’ : ‘nice’
‘count’ : 2
‘rank’ : 1
},
{
‘word’ : ‘Something’
‘count’ : 2
‘rank’ : 2
},
{
‘word’ : ‘A’
‘count’ : 1
‘rank’ : 3
}
}
and so on ... etc
以下は、私はそれを達成することができますどのように私を助けたり、私がここで間違っ
やって聞かせてくださいすることができ、私は以下のコードを使用していますが、私のような除外出力としての私のJの息子形式のいくつかで出力を必要とします
? –
が1番、2番が最高です... 2番など... jsonはサンプル用です。私はちょうど –
というフォーマットですので、 'arsort($ frequency);'の後ろに配列してください。 '$ frequency'を出力し、データを表示します。 (あなたの質問に追加してください) –