Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove 
 char from imap mail extract
    text
    copied!<p>i am trying to fetch a mail in imap from google, i'm using the imap() function from PHP IMAP library and i want to use a preg_match() call on my mail content but i have a strange issue, i have curious break lines altering the normal preg_match().</p> <p>More details: I have in my markup something like that:</p> <pre><code>&lt;TABLE CELLPADDING=5 RULES=GROUPS FRAME=BOX&gt; &lt;THEAD&gt; &lt;TR&gt; &lt;TH&gt;Résumé points de classement&lt;/TH&gt; &lt;TH&gt;Extérieur&lt;/TH&gt; &lt;TH&gt;Domicile&lt;/TH&gt; &lt;/TR&gt; &lt;/THEAD&gt; &lt;TBODY&gt; &lt;TR&gt; &lt;TD&gt;Équipe&lt;/TD&gt; &lt;TD&gt;Milan&lt;/TD&gt; &lt;TD&gt;Arsenal&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt;Performance du match&lt;/TD&gt; &lt;TD&gt;0&lt;/TD&gt; &lt;TD&gt;19&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt;Étoiles équipe&lt;/TD&gt; &lt;TD&gt;0&lt;/TD&gt; &lt;TD&gt;0&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt;Points totaux&lt;/TD&gt; &lt;TD&gt;3195&lt;/TD&gt; &lt;TD&gt;3273&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt;Niveau actuel&lt;/TD&gt; &lt;TD&gt;22&lt;/TD&gt; &lt;TD&gt;22&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt;Points pour le prochain niveau&lt;/TD&gt; &lt;TD&gt;5&lt;/TD&gt; &lt;TD&gt;127&lt;/TD&gt; &lt;/TR&gt; &lt;/TBODY&gt; &lt;/TABLE&gt; </code></pre> <p>I am running this code to extract the body for example:</p> <pre><code>&lt;?php // $message is the previous markup. $str = substr($message, 321, 10); var_dump($str); $str = preg_replace("/&amp;#10;/i","",$str); var_dump($str); ?&gt; </code></pre> <p>The output of this code is:</p> <pre><code>&lt;pre class='xdebug-var-dump' dir='ltr'&gt;&lt;small&gt;string&lt;/small&gt; &lt;font color='#cc0000'&gt;' &amp;#10; &amp;#10;&amp;amp;lt;TABLE'&lt;/font&gt; &lt;i&gt;(length=13)&lt;/i&gt; &lt;/pre&gt; &lt;pre class='xdebug-var-dump' dir='ltr'&gt;&lt;small&gt;string&lt;/small&gt; &lt;font color='#cc0000'&gt;' &amp;#10; &amp;#10;&amp;amp;lt;TABLE'&lt;/font&gt; &lt;i&gt;(length=13)&lt;/i&gt; &lt;/pre&gt; </code></pre> <p>And the extracted value is an empty array... After further investigation i discovered through a var_dump() of my source string that there is a &#10; at the end of each line. I have no clue of what this html char code is and how to remove it.</p> <p>If you can enlight me, i'll be thankfull ;)</p> <p>Have a nice day!</p> <p>EDIT: With a str_replace() it works! &#10; is in fact the \n break line. So the magic tricks is:</p> <pre><code>$overview = imap_body($inbox,$email_number,0); $message = utf8_decode(quoted_printable_decode($overview)); $message = str_replace("\n", "", $message); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload