$fio = "Иванов Иван Иванович"; 

Is there a declination algorithm for the full name? in php in genitive?

Found algorithms for declining name, but not in the genitive case or not for PHP. Ideally, 2 different solutions are better (simpler and more complicated).

2 answers 2

This topic is also interesting to me. copied the first code, added from the bottom:

 $r = new NCLNameCaseRu(); $r->setLastName('Черепаншин'); $r->setFirstName('Рафаэль'); $r->setFatherName('Микельанжелович'); $r->setGender(1); echo $r->getFormatted(2); 

Similarly: Cherepanshina Rafael Mikelanzhelovich.

  • those. leaning surname. and that's it - Iukpun
  • Set the correct floor ... $ r-> setGender (0); - Alex Kapustin pm
  • the floor is correct. it's just the first time I made a typo. it turns out: Cherepanshina Rafael Mikelanzhelovich - Iukpun
  • and I have everything ... - Alex Kapustin

Encoding with class file must be in ANSI. The class is called as follows:

 include ("NCLNameCaseRu.php"); $r = new NCLNameCaseRu(); $r->setFirstName(iconv('cp1251', 'utf-8', 'Иван')); $r->setLastName(iconv('cp1251', 'utf-8', 'Иванов')); $r->setFatherName(iconv('cp1251', 'utf-8', 'Иванович')); $r->setGender(0); echo iconv('utf-8', 'cp1251', $r->getFormatted(2)); 

Provided that the document where the class is called is in our cp1251 encoding. Verified, everything works!

  • I decided the question a long time ago, but I’ll know about how to connect and use a file in a different encoding. You do not save yourself comrade, on the forum, but on the day off! - sergey