-1

I'm having an issue with the function str_word_count() with my PHP.

I have this piece of code:

$array_cadena = str_word_count($row[0]);
echo "<td>";
for ($i = 0; $i < $half_words; $i++) {
    echo $array_cadena[$i] . " ";
};

It works without problems, but if I leave the code like that I'll experience problems with the accents, punctuation marks and numbers. So I decided to add the following...

$array_cadena = str_word_count($row[0], 1,'1,2,3,4,5,6,7,8,9,0,á,é,í,ó,ú,ñ,.,;');

But in the browser, I see this error: Notice: Undefined offset:

What am I doing wrong?

Thanks for your help.

Karl Hill
  • 12,937
  • 5
  • 58
  • 95

1 Answers1

0

Use the char list without comman as follows:

$array_cadena = str_word_count($row[0], 1,'1234567890áéíóúñ.,;');
Md Monjur Ul Hasan
  • 1,705
  • 1
  • 13
  • 36