-1
The variable $words
concatenates the result of a query into a column of a table where words are separated by comma.
Only that when running the script for each word inside the for is is generated a PHP Notice: Undefined index: agua in ....
If there are 50 words will be generated 50 PHP Notice: Undefined index: PALAVRA_DO_FOR in ...
$palavras = explode(',', $words);
$ocorrencias = array();
for($i = 0; $i<count($palavras); $i++){
$palavra = $palavras[$i];
$ocorrencias[$palavra]++;
}
How to avoid these PHP Notice: Undefined index: ...
?
PHP Version 5.4.43
can I know why the negative? I should know how to solve this kind of doubt? I searched related and did not find
– user60252
Checks if the key exists with
isset
and if it does not exist, create it before using it.– Woss
@Andersoncarloswoss did not understand how to do this, could post as response?
– user60252