【发布时间】:2009-10-31 03:26:08
【问题描述】:
我想创建一个包含两列的数组。输出应仅包含单词中的现有字母及其数量。
以下代码的想要的输出
a 3
s 2
p 1
以下 PHP 代码有什么问题?
<?php
$alpha = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','z','y');
$word = "saapas";
for ( $i = 0; $i < count($word); $i++ ) {
echo $word[$i] . "\n";
$table[$word[$i]][]++; // Problem here
}
// array_unique, array_combine and some method which can sort arrays by alphabets can be useful
【问题讨论】:
-
你在哪里使用 $alpha?