Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am using Codeigniter framework of PHP and trying to extract keywords from the page. The complete code for reference can be seen
here
. It is not ready-made though.
The issue is due to the array function in the following line:
$keywordCounts = array_count_values( $words );
The error message being displayed is as follows:
A PHP Error was encountered
Severity: Warning
Message: array_count_values() [function.array-count-values]: Can only count STRING and INTEGER values!
EDITED: The array $words for reference can be found here.
There are no special symbols or invalid characters to my knowledge in the $words array. Hyphens and periods are not read by the function or is there some other issue ?
–
–
–
–
you have null
values in your array. you have to replace them before working with array_count_values
like this:
$x = array('s'=>'ss', 'a',4 , 'sss' => null);
$ar = array_replace($x,array_fill_keys(array_keys($x, null),''));
$v = array_count_values($ar);
var_dump($v);
which will result:
array (size=4)
'ss' => int 1
'a' => int 1
4 => int 1
'' => int 1
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.