title: PHP - forwardslash between main page and subpages
body: <p>Wondering how to have a forward slash between a main page and its subpages.</p>
  
  <p><strong>Current outcome</strong>
  mywebsite.com/page1-subpage.php</p>
  
  <p><strong>Desired outcome:</strong>
  mywebsite.com/page1/subpage.php</p>
  
  <p>When trying to use a slash in this bit of code gives me an error message: "/".$page->url</p>
  
  <p><strong>Full code below</strong></p>
  
  <pre><code>if($page-&gt;parent &gt; 1){
      $l = getParentById($page-&gt;parent,$pages);
      $page-&gt;url = remove_accents($l-&gt;title)."-".$page-&gt;url;
      }
  </code></pre>
  
  <p>When using the original "_" or a "-", everything works just fine.</p>
  
  <p>Can somebody help me out please? I guess this quite an easy issue. Thanks in advance!</p>
  
  <hr>
  
  <p><strong>EDIT</strong>
  Additional code. Hope this makes some sense.</p>
  
  <pre><code>if(!$page-&gt;title){
      PError("Please fill in a page title.");
      }
      $page-&gt;type = sprintf("%s",Utilities::scrub($_POST['type']));
      $page-&gt;url = sprintf("%s",Utilities::scrub($_POST['url']));
  
  
  if($page-&gt;type=='page'){
      $page-&gt;url = remove_accents($page-&gt;title).".php";
  
  
  if($page-&gt;parent &gt; 1){
      $l = getParentById($page-&gt;parent,$pages);
      $page-&gt;url = remove_accents($l-&gt;title)."/".$page-&gt;url;
      }
  //print_r($page);
  //exit;
  
  if((!$page-&gt;id)&amp;&amp;(file_exists("../".$page-&gt;url))){
      PError("Page title already exists. Please choose another title.");
      exit();
      }
  }
  
  if($page-&gt;type == 'link'){
  
  if(!$page-&gt;url){
      PError("Fill in a URL.");
      }
  
  }
  
  $page-&gt;display = sprintf("%s",Utilities::scrub($_POST['display']));
  
  $new=0;
  if(!$page-&gt;id){
      $page-&gt;id = uniqid();
      $new=1;
      }
  
  if(SaveHeaderImage($page-&gt;id)){
      $page-&gt;headerimage = sprintf("%s",Utilities::scrub($_FILES['headerimage']['name']));
      }
  
  if($new){
      array_push($pages,$page);
  }
  else{
  
      foreach($pages as &amp;$l){
          if($l-&gt;id == $page-&gt;id){
              $l = $page;
              break;
              }
          unset($l);
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT 2: Function</strong></p>
  
  <pre><code>function remove_accents($string)
  {
  
  $table = array(
      'Š' =&gt; 'S', 'š' =&gt; 's', 'Ð' =&gt; 'Dj', 'ð' =&gt; 'dj', 'Ž' =&gt; 'Z', 'ž' =&gt; 'z', '?' =&gt; 'C', '?' =&gt; 'c', '?' =&gt; 'C', '?' =&gt; 'c',
      'À' =&gt; 'A', 'Á' =&gt; 'A', 'Â' =&gt; 'A', 'Ã' =&gt; 'A', 'Ä' =&gt; 'A', 'Å' =&gt; 'A', 'Æ' =&gt; 'A', 'Ç' =&gt; 'C', 'È' =&gt; 'E', 'É' =&gt; 'e',
      'Ê' =&gt; 'E', 'Ë' =&gt; 'E', 'Ì' =&gt; 'I', 'Í' =&gt; 'I', 'Î' =&gt; 'I', 'Ï' =&gt; 'I', 'Ñ' =&gt; 'n', 'Ò' =&gt; 'O', 'Ó' =&gt; 'O', 'Ô' =&gt; 'O',
      'Õ' =&gt; 'O', 'Ö' =&gt; 'O', 'Ø' =&gt; 'O', 'Ù' =&gt; 'U', 'Ú' =&gt; 'U', 'Û' =&gt; 'U', 'Ü' =&gt; 'U', 'Ý' =&gt; 'Y', 'Þ' =&gt; 'B', 'ß' =&gt; 'Ss',
      'à' =&gt; 'a', 'á' =&gt; 'a', 'â' =&gt; 'a', 'ã' =&gt; 'a', 'ä' =&gt; 'a', 'å' =&gt; 'a', 'æ' =&gt; 'a', 'ç' =&gt; 'c', 'è' =&gt; 'e', 'é' =&gt; 'e',
      'ê' =&gt; 'e', 'ë' =&gt; 'e', 'ì' =&gt; 'i', 'í' =&gt; 'i', 'î' =&gt; 'i', 'ï' =&gt; 'i', 'ð' =&gt; 'o', 'ñ' =&gt; 'n', 'ò' =&gt; 'o', 'ó' =&gt; 'o',
      'ô' =&gt; 'o', 'õ' =&gt; 'o', 'ö' =&gt; 'o', 'ø' =&gt; 'o', 'ù' =&gt; 'u', 'ú' =&gt; 'u', 'û' =&gt; 'u', 'ý' =&gt; 'y', 'ý' =&gt; 'y', 'þ' =&gt; 'b',
      'ÿ' =&gt; 'y', '?' =&gt; 'R', '?' =&gt; '?',
  );
  
  $string = strtr($string, $table);
  $string = strtolower($string);
  $string = preg_replace('#[^a-z0-9/]+#', '-', $string);
  $string = trim($string, '-');       
  return $string; 
  }
  </code></pre>