Home  >  Article  >  Backend Development  >  php字符轮换

php字符轮换

WBOY
WBOYOriginal
2016-06-13 12:52:00834browse

php字符替换
$str = "我是中国人sdfsfsfsdf php字符轮换 fsadfsf php字符轮换 ";
$ar  = array("a.jpg","b.jpg");

如果将 php字符轮换 替换成a.jpg
 php字符轮换 替换成b.jpg

形成"我是中国人sdfsfsfsdffsadfsf";


------解决方案--------------------
$keys=array('img1','img2');
echo strtr($str,array_combine($keys,$ar));

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn