How to write the Chinese version of PHP Longest common subsequence problem LCS?

  question

The ASCII alphabet has been written.

function LCS($str_1, $str_2) {
 $len_1 = strlen($str_1);
 $len_2 = strlen($str_2);
 $len = $len_1 > $len_2 ?   $len_1 : $len_2;
 
 $dp = array();
 for ($i = 0;   $i <= $len;  $i plus)
 $dp[$i] = array();
 $dp[$i][0] = 0;
 $dp[0][$i] = 0;
 bracket
 
 for ($i = 1;   $i <= $len_1;  $i plus)
 for ($j = 1;   $j <= $len_2;  $j plus)
 if ($str_1[$i - 1] == $str_2[$j - 1]) {
 $dp[$i][$j] = $dp[$i-1][$j-1] plus 1;
 } else {
 $dp[$i][$j] = $dp[$i - 1][$j] > $dp[$i][$j - 1] ?   $dp[$i - 1][$j] : $dp[$i][$j - 1];
 bracket
 bracket
 bracket
 
 return $dp[$len_1][$len_2];
 bracket

How to expand to Chinese version?

I have solved it myself and can only ask myself and answer it myself.

<?  Php
 //Longest common subsequence problem English Version
 function LCS_en($str_1, $str_2) {
 $len_1 = strlen($str_1);
 $len_2 = strlen($str_2);
 $len = $len_1 > $len_2 ?   $len_1 : $len_2;
 
 $dp = array();
 for ($i = 0;   $i <= $len;  $i plus)
 $dp[$i] = array();
 $dp[$i][0] = 0;
 $dp[0][$i] = 0;
 bracket
 
 for ($i = 1;   $i <= $len_1;  $i plus)
 for ($j = 1;   $j <= $len_2;  $j plus)
 if ($str_1[$i - 1] == $str_2[$j - 1]) {
 $dp[$i][$j] = $dp[$i-1][$j-1] plus 1;
 } else {
 $dp[$i][$j] = $dp[$i - 1][$j] > $dp[$i][$j - 1] ?   $dp[$i - 1][$j] : $dp[$i][$j - 1];
 bracket
 bracket
 bracket
 
 return $dp[$len_1][$len_2];
 bracket
 
 //Split string
 function mbStringToArray($string, $encoding = 'UTF-8') {
 $arrayResult = array();
 
 while ($iLen = mb_strlen($string, $encoding)) {
 array_push($arrayResult, mb_substr($string, 0, 1, $encoding));
 $string = mb_substr($string, 1, $iLen, $encoding);
 bracket
 
 return $arrayResult;
 bracket
 
 //Longest common subsequence problem Chinese Version
 function LCS_cn($str1, $str2, $encoding = 'UTF-8') {
 $mb_len1 = mb_strlen($str1, $encoding);
 $mb_len2 = mb_strlen($str2, $encoding);
 
 $mb_str1 = mbStringToArray($str1, $encoding);
 $mb_str2 = mbStringToArray($str2, $encoding);
 
 $len = $mb_len1 > $mb_len2 ?   $mb_len1 : $mb_len2;
 
 $dp = array();
 for ($i = 0;   $i <= $len;  $i plus)
 $dp[$i] = array();
 $dp[$i][0] = 0;
 $dp[0][$i] = 0;
 bracket
 
 for ($i = 1;   $i <= $mb_len1;  $i plus)
 for ($j = 1;   $j <= $mb_len2;  $j plus)
 if ($mb_str1[$i - 1] == $mb_str2[$j - 1]) {
 $dp[$i][$j] = $dp[$i-1][$j-1] plus 1;
 } else {
 $dp[$i][$j] = $dp[$i - 1][$j] > $dp[$i][$j - 1] ?   $dp[$i - 1][$j] : $dp[$i][$j - 1];
 bracket
 bracket
 bracket
 
 return $dp[$mb_len1][$mb_len2];
 bracket