title: PHP - select first 40 words of a message retrieved with Facebook PHP SDK
body: <p>I am using Facebook PHP SDK to display my fan page feeds on my website. However the feeds are too long so I need to select only the 40 first word. 
  After some research I found that this code is what I need but because I don't know how to insert it in my php. </p>
  
  <pre><code>implode(' ', array_slice(explode(' ', $post['message'], 0, 40));
  </code></pre>
  
  <p>My php is accessing facebook with the graph API and here is my php:</p>
  
  <pre><code>    &lt;?php
  
      echo "&lt;div class=\"fb-feed\"&gt;";
      foreach ($pagefeed['data'] as $post) {
  
  
      if ($post['type'] == 'link') {
  
      echo "&lt;p&gt;" . $post['message'] . "&lt;/p&gt;";
  
      }
  
      echo "&lt;/div&gt;"; // close fb-update div
  
      $i++; // add 1 to the counter if our condition for $post['type'] is met
      }
  
      } // end the foreach statement
  
      ?&gt;
  </code></pre>
  
  <p>Thanks a lot for your help!</p>