use*_*810 0 php arrays encryption passwords hash
<?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);
?>
Run Code Online (Sandbox Code Playgroud)
我明白了
Encrypted: Array
Run Code Online (Sandbox Code Playgroud)
但我期待
Encrypted: Al01Br20Ch03De40Ec05Fo60
Run Code Online (Sandbox Code Playgroud)
我如何获得哈希值作为回报?
你得到str_replace()
错误的参数顺序:
$hashed = str_replace( $replace_from, $replace_to, $string );
Run Code Online (Sandbox Code Playgroud)
正确的顺序是