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']);
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);
Try something like this
<?php
$str='http://www.example.com/Music/\2011 Hits\Balle Lakka.mp3';
$str=str_replace(array('\\','//',':'),'/',$str);
echo $str;
OUTPUT:
http://www.example.com/Music/2011 Hits/Balle Lakka.mp3
$file = str_replace('\\','/',$file);
add it to the end. It should work..
in while loop you can do following:
while(list($key,$value) = each($data))
$arr[$i][$key] = ($key!='filename') ? $value : str_replace('\\','/', ltrim($value, '\\'));