Function : to_namespace

This function performs three operations. It converts frontslashes to backslash, removes a trailing front or back slashes suffix from the end of a url and decides if a prefix trailing slash is to be added to the supplied url. This in simple terms means that any url supplied is converted to a namespace pattern with or without a prefix trailing backslash.

Syntax
  to_namespace($url, $dots)
   
  $url  : supplied url string
  $prefix : a boolean value of true adds a backslash prefix
   
                  
Sample 1
  $text = to_namespace('some/url'); 

  var_dump( $text ); // some\url  
                  
Sample 2
  $text = to_namespace('some/url', true); 

  var_dump( $text ); // \some\url  
                  
It is should be noted that dots are never converted to slashes. To convert dots to backslash see to_dotspace documentation.