title: Check if a string is larger than 2 megabytes in php
body: <p>How in <strong>php</strong> can I check if a string is larger than 2 MB? We need to truncate strings that are large before inserting them into MongoDB, since the MongoDB document limit is 16MB.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The string can indeed have non ascii characters, i.e. utf.</p>