PHP Function Reference

PHP convert_cyr_string() Function



The PHP convert_cyr_string() function converts a string from one Cyrillic character set to another. This is a binary-safe function. The supported Cyrillic character sets are:

  • k - koi8-r
  • w - windows-1251
  • i - iso8859-5
  • a - x-cp866
  • d - x-cp866
  • m - x-mac-cyrillic
Note: This function has been DEPRECATED as of PHP 7.4.0, and REMOVED as of PHP 8.0.0.

Syntax

convert_cyr_string(string, from, to)

Parameters

string Required. Specify the string to be converted.
from Required. Specify the source Cyrillic character set, as a single character.
to Required. Specify the target Cyrillic character set, as a single character.

Return Value

Returns the converted string.

Example:

The example below demonstrates the usage of convert_cyr_string() function.

<?php
$str = "AlphaCodingSkills æøå???øåæøå";
echo $str."\n";

//converting from character-set 
//'w' (windows-1251) to 'k' (koi8-r)
echo convert_cyr_string($str,'w','a');
?>

The output of the above code will be:

AlphaCodingSkills æøå???øåæøå
AlphaCodingSkills �.�� ???�� �.��

❮ PHP String Reference