汉字怎么在汉字前加md5函数

how to chinese character add md5 function before chinese

Hi all I want add md5 to chinese character, but not working

ex: 你好,我是Jack!

to: df1fd9101108b40d26977a8d0bb9fd1e-你, ac2c8f13c6e60810197b19d683f5f184-好, 16815254531798dc21ee979d1d9c6675-我, 0a60ac8f02ccd2cf723f927284877851-是, Jack!

My code:

$data = "你好,我是Jack!";

$data = preg_replace('/(\p{Han}+)/u',md5('')-,$data);

echo $data;

使用preg_replace_callback()。

$data = "你好,我是Jack!";

$data2 = preg_replace_callback(
  '/(\p{Han})/u',
   function($matches){return md5($matches[1])."-".$matches[1];},
  $data
);