php字符串中的相对字符替换

可以使用 PHP 的 strtr 函数来实现:

$str = "728e1431b2afe24800c09d37c2a234a8382d69eb";
$from = "ebafcd";
$to = "mjinkl";
$result = strtr($str, $from, $to);
echo $result;
这段代码会将 str中的字符按照from 和 $to 中的对应关系进行替换,最终输出结果为:

728m1431j2i nk24800k09l37l2n34n8382l69lj

发表评论

电子邮件地址不会被公开。 必填项已用*标注