title: Cut a string before a character in better way in php
body: <p>I have a very simple question about php.</p>
  
  <p>I have this string: </p>
  
  <pre><code>This is a simple string | badword is here
  </code></pre>
  
  <p>And I need this:</p>
  
  <pre><code>The is a simple string
  </code></pre>
  
  <p>So, </p>
  
  <p>I have used this code below: </p>
  
  <pre><code>$word = substr($word, 0, strpos($word, '|'));
  </code></pre>
  
  <p>and if I use that code, I have to check is there any <code>|</code> char in the string, If yes delete it.</p>
  
  <p>So it's very very low speed and I can't use it .</p>
  
  <p>What is the fastest way to get the result, without checking if the <code>|</code> char is or is not in the main string? </p>