donglu9445 2013-11-03 07:03
浏览 45
已采纳

在http中使用http:// forward slashes str_replace()替换本地路径反斜杠

I get the following result :http://www.example.com/Music/\2011 Hits\Balle Lakka.mp3

Following is str_replace to try and replace local path URL to http:// path:

@mysql_select_db($database) or die( "Unable to select database");
            $query = "SELECT songlist.* FROM songlist WHERE ID='".$song->ID."'";    
            $result = mysql_query($query,$conn);
            $i=0;
            while($data = mysql_fetch_assoc($result)) 
            {
                while(list($key,$value) = each($data))
                    $arr[$i][$key] = $value;
                $i++;
            }

             $file  = str_replace("C:\inetpub\Music","http://www.example.com/Music/",$arr[0]['filename']);
  • 写回答

4条回答 默认 最新

  • doujiang6944 2013-11-03 07:12
    关注

    Can you please try this,

    Simply:

    echo $url = str_replace("/\\","/",$url);
    

    another method,

    $url = str_replace("C:\inetpub\Music","http://www.mydomain.com/Music/","http://www.mydomain.com/Music/2011 Hits/\Balle Lakka.mp3");
    
    $url = str_replace("\\","/",$url);
    $url = str_replace("//","/",$url);
    echo $url = str_replace("http:/","http://",$url);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常