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条)

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿