title: Create complex string from another string
body: <p>I have the following string:</p>
  
  <pre><code>$string = "a/b/c/d/e/f/g";
  </code></pre>
  
  <p>I want to create another string with the following structure:</p>
  
  <pre><code>$return = "a|a/b|a/b/c|a/b/c/d|a/b/c/d/e|a/b/c/d/e/f|a/b/c/d/e/f/g";
  </code></pre>
  
  <p>I tried to create an array from the first string and use two loop but it is not working.</p>
  
  <p>Can you help me please?</p>