There is a function of 'output endings':

function plural_type($n) {return ($n%10==1 && $n%100!=11 ? 0 : ($n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? 1 : 2));} $_plural_msg = array('сообщСниС', 'сообщСния', 'сообщСний'); $_plural_piple = array('Ρ‡Π΅Π»ΠΎΠ²Π΅ΠΊ', 'Ρ‡Π΅Π»ΠΎΠ²Π΅ΠΊΠ°', 'Ρ‡Π΅Π»ΠΎΠ²Π΅ΠΊ'); $_plural_comm = array('ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ', 'коммСнтария', 'ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠ΅Π²'); $_plural_zap = array('запись', 'записи', 'записСй'); 

Called for example as follows:

 echo 'Π’ Π³Ρ€ΡƒΠΏΠΏΠ΅ - '.$_plural_piple[plural_type($row["count"])]; 

For this business 4 arrays are created. But something does not give me rest. Is it somehow not optimized, or is it more rational to cram arrays inside the function plural_type ? Can you please tell how you can modify this function on the site?

    1 answer 1

    Well, I would just pass possible words to the function ..