Note that there are some explanatory texts on larger screens.

plurals
  1. POwriting special characters to txt file
    primarykey
    data
    text
    <p>I am reading some data from a remote file, got every thing working till the point when i write some specific lines to a text file.<br> problem here is, when i write something like <strong>Girl's Goldtone 'X' CZ Ring</strong> it becomes <strong><em>Girl &amp; apos;s Goldtone &amp;apos ;X &amp; apos; CZ Ring</em></strong> in txt file.<br> how do i write to txt file so that it retains text like written above and not show character code but actual character.<br> sample of my code. </p> <pre><code>$content_to_write = '&lt;li class="category-top"&gt;&lt;span class="top-span"&gt;&lt;a class="category-top" href="'.$linktext.'.html"&gt;'.$productName.'&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;'."\r\n"; fwrite($fp, $content_to_write); $linktext = "Girls-Goldtone-X-CZ-Ring"; $productName = "Girl's Goldtone 'X' CZ Ring"; </code></pre> <p><strong>var_dump</strong> </p> <pre><code>string '&lt;li class="category-top"&gt;&lt;span class="top-span"&gt;&lt;a class="category-top" href="Stellar-Steed-Gallery-wrapped-Canvas-Art.html"&gt;&amp;apos;Stellar Steed&amp;apos; Gallery-wrapped Canvas Art&lt;/a&gt;&lt;/span&gt;&lt;/li&gt; </code></pre> <p>' (length=195)</p> <p><strong>Code</strong></p> <pre><code> $productName =$linktext; $linktext = str_replace(" ", "-", $linktext); $delChar = substr($linktext, -1); if($delChar == '.') { $linktext = substr($linktext, 0, -1); } $linktext = removeRepeated($linktext); $linktext = remove_invalid_char($linktext); $productName = html_entity_decode($productName); $content_to_write = '&lt;li class="category-top"&gt;&lt;span class="top-span"&gt;&lt;a class="category-top" href="'.$linktext.'.html"&gt;'.$productName.'&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;'."\r\n"; var_dump($content_to_write); fwrite($fp, utf8_encode($content_to_write)); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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