我正试着读str_replace的内容,但是我什么也找不到。我有这样的代码,它工作得很好(文本文件包含: track - artist),只要在音轨或艺术家的名字中没有“‘”,这很常见:)在输出中用“-”替换它,应该工作(我希望)但是如何?
<?php
$file = "lyrics.txt";
if (0 < filesize($file)) {
$myfile = fopen("lyrics.txt", "r") or die("Splat!");
echo "<a href='https://www.musixmatch.com/search/";
echo fread($myfile,filesize("lyrics.txt"));
echo "'target='_blank'><span title='Search lyrics' class='button'>Musixmatch</span> <a/>";
fclose($myfile);
}
?>发布于 2017-07-12 16:24:11
str_replace期望使用搜索字符串、替换字符串和字符串,并返回一个带有替换值的新字符串(这可能是您的问题)。
就这么简单:
<?php
$input = "some 'foo' with 'bar'";
$input = str_replace("'", "-", $input);
echo $input;
?>指纹:
some -foo- with -bar-(PHP沙箱)
https://stackoverflow.com/questions/45062959
复制相似问题