title: How to slice a string in PHP?
body: <p>Ok, so I've got this string: </p>
  
  <pre><code>"MICROSOFT CORP CIK#: 0000789019 (see all company filings)"
  </code></pre>
  
  <p>And I would like to cut off everything after the <code>"CORP"</code> bit. How would I go about doing this in PHP? I am used to Python so I am not sure how this is done.</p>
  
  <p>To be clear, this is the output I want:</p>
  
  <pre><code>"MICROSOFT CORP"
  </code></pre>
  
  <p>I am trying:</p>
  
  <pre><code>$companyname = substr($companyname, 0, strpos($companyname, " CIK"));
  </code></pre>
  
  <p>and I am getting nothing showing.</p>
  
  <p>Here is my full code:</p>
  
  <pre><code>&lt;?php
  include 'simple_html_dom.php';
  $html = file_get_html('http://www.sec.gov/cgi-bin/browse-edgar?company=&amp;match=&amp;CIK=MSFT&amp;filenum=&amp;State=&amp;Country=&amp;SIC=&amp;owner=exclude&amp;Find=Find+Companies&amp;action=getcompany');
  $companyname = $html-&gt;find('span[class=companyName]', 0);
  $companyname = substr($companyname, 0, strpos($companyname, " CIK#")+5);
  $bizadd = $html-&gt;find('div[class="mailer"]');
  echo $companyname;
  echo "&lt;br /&gt;";
  foreach ($bizadd as $value) {
      $addvals = $value-&gt;find('span[class="mailerAddress"]');
      echo "&lt;br /&gt;";
      foreach ($addvals as $value) {
          echo $value;
          echo "&lt;br /&gt;";
      }
  }
  ?&gt;
  </code></pre>