I want to create an array which has two columns. The output should contain only the existing letters in the word with their amounts.
The wanted output of the following code
a 3
s 2
p 1
What is wrong in the following PHP code?
<?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