Search code examples
phpfwrite

writing file name - fwrite need to delimit "/"


I'm pulling part numbers from a database and creating a series of flat html file using fwrite

$title = $row['PartNo']."_".$row['Title'];
$navigation = str_replace(" ","-",$title);
$navigation=$navigation.".html";
$fhandle = fopen($navigation,"w");
fwrite($fhandle,$content);
fclose($fhandle)

The problem is that some of the part number have a '/' Is there a way of delimiting a '/' (slash) within a file name so it is not view as a change of path?


Solution

  • No. A slash in a filename is a path separator. You'll have to replace it with a different character before opening the file.