title: How to convert double backslash in string to one backslash in PHP?
body: <p>I need a to generate a string like this, <code>Helpers\Name</code>.</p>
  
  <p>I have a <code>$prefix</code> that contains <code>\\</code> like <code>$prefix = "Helpers\\";</code></p>
  
  <p>When I merge the strings like below, It returns a string with double backslashes instead of one!</p>
  
  <p><code>$what_i_want = $prefix . 'Name'; // return Helpers\\Name</code> </p>
  
  <p>After that result, I tried to replace the double backslashes by one with <code>str_repleca()</code> and <code>preg_replace()</code>methods but it does not work!</p>
  
  <p>Any solution will be appreciated. </p>
  
  <p><strong>Update:</strong>
  Here is my helper function in Laravel which I want to return what I want:</p>
  
  <pre><code>public static function getModelsClassesByString()
  {
      $path = app_path();
      $models = [];
      $prefix = "App\\";
      $results = scandir($path);
  
      foreach ($results as $result) {
          if ($result === "." or $result === "..") continue;
          $filename = $prefix . $result;
          $models[] = substr($filename, 0, -4);
      }
      return $models;
  
  }
  </code></pre>
  
  <p>the function return like below:</p>
  
  <p><code>["App\\Admin", "App\\User",...]</code></p>
  
  <p>Also, I really don't understand someone who could not help but let itself to destroy the question and my needs by down votes or destructor comments. </p>