PHP Tutorial - PHP convert_cyr_string() Function






Definition

The convert_cyr_string() function converts a string from one Cyrillic character-set to another.

Syntax

PHP convert_cyr_string() function has the following syntax.

convert_cyr_string(string,from,to)

Parameter

ParameterIs RequiredDescription
stringRequired. The string to convert
fromRequired. A character that specifies what Cyrillic character-set to convert from
toRequired. A character that specifies what Cyrillic character-set to convert to

Supported Cyrillic character-sets

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

This function is binary-safe.





Return

PHP convert_cyr_string() Function returns the converted string.

Example

Convert a string from one character-set to another:


<?php
$str = "Hello world from java2s.com!";
echo $str . "\n";
echo convert_cyr_string($str,'w','a');
?>

The code above generates the following result.