<?php
$text = <<<EOF
Это - хорошо
EOF;
$words = [];
$wordFounder = "/[\p{L}\-\_]+/ui";
$result = [];
$words = $pregResult[0];
echo "Всего слов в тексте - $count.\n";
foreach ($result as $word => $count) {
echo "$word - встречается $count раз.\n";
}
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CgokdGV4dCA9IDw8PEVPRgrQrdGC0L4gLSDRhdC+0YDQvtGI0L4KRU9GOwoKJHRleHQgPSBtYl9zdHJ0b2xvd2VyKCR0ZXh0KTsKJHdvcmRzID0gW107CiR3b3JkRm91bmRlciA9ICIvW1xwe0x9XC1cX10rL3VpIjsKJGNvdW50ID0gcHJlZ19tYXRjaF9hbGwoJHdvcmRGb3VuZGVyLCAkdGV4dCwgJHByZWdSZXN1bHQpOwokcmVzdWx0ID0gW107CiR3b3JkcyA9ICRwcmVnUmVzdWx0WzBdOwokcmVzdWx0ID0gYXJyYXlfY291bnRfdmFsdWVzKCR3b3Jkcyk7CmFyc29ydCgkcmVzdWx0KTsKCQplY2hvICLQktGB0LXQs9C+INGB0LvQvtCyINCyINGC0LXQutGB0YLQtSAtICRjb3VudC5cbiI7Cgpmb3JlYWNoICgkcmVzdWx0IGFzICR3b3JkID0+ICRjb3VudCkgewoJZWNobyAiJHdvcmQgLSDQstGB0YLRgNC10YfQsNC10YLRgdGPICRjb3VudCDRgNCw0LcuXG4iOwp9Cgo=