I have written a java code and I need help writing it in PHP because I do not have enough experience with PHP
public static String mo31385a(String str, String str2, String str3) { int length = str.length(); char[] cArr = new char[length]; for (int i = 0; i < length; i++) { char charAt = str.charAt(i); int indexOf = str2.indexOf(charAt); if (indexOf < 0) { cArr[i] = charAt; } else { cArr[i] = str3.charAt(indexOf); } } return new String(cArr); }
i want thes function by php plz
Advertisement
Answer
Here:
function mo31385a($str, $str2, $str3) { $cArr = array(); for ($i = 0; $i < strlen($str); $i++) { $charAt = $str[$i]; $indexOf = strpos($str2,$charAt); if (!$indexOf) { $cArr[] = $charAt; continue; } $cArr[] = $str3[$indexOf]; } return implode("",$cArr); }