<?php
error_reporting(E_ALL ^ E_NOTICE);
$string = "123456";
$replace_from = array(
"1",
"2",
"3",
"4",
"5",
"6");
$replace_to = array(
"Al01",
"Br20",
"Ch03",
"De40",
"Ec05",
"Fo60");
$hashed = str_replace($string, $replace_from, $replace_to);
echo "String: ". $string ."<br>";
echo "Encrypted: ". $hashed ."<br>";
echo "<br>";
print_r($hashed);
?>
我得到了
Encrypted: Array
但我期待
Encrypted: Al01Br20Ch03De40Ec05Fo60
如何将哈希作为回报?
答案 0 :(得分:6)
您的参数顺序为str_replace()
错误:
$hashed = str_replace( $replace_from, $replace_to, $string );
正确的顺序是