Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Actually user code is correct and working also correct. But unfortunately is not returning any character with 150 character. Try 5000 .</p> <pre><code>$trim_string = substr($string, 0, 5000); </code></pre> <p>To understand this problem see view source.</p> <p>You can use this code instead of your and definitely it will work:</p> <pre><code>$url = 'http://crewow.com/CSS_Layout_Tutorial.php'; $data = file_get_contents($url); $content = plaintext($data); //echo trim($content); $Preview = trim_display(150,trim($content)); //to Show first 100 char of the web page as preview echo $Preview; function trim_display($size,$string) { //echo "string is : $string &lt;br/&gt;"; $trim_string = substr($string, 0, 150); $trim_string = $trim_string . "..."; //echo "Trim string is $trim_string &lt;br/&gt;"; return $trim_string; } function plaintext($html) { $plaintext = preg_replace('#([&lt;]title)(.*)([&lt;]/title[&gt;])#s', ' ', $html); // remove title //$plaintext = preg_match('#&lt;title&gt;(.*?)&lt;/title&gt;#', $html); // remove comments and any content found in the the comment area (strip_tags only removes the actual tags). $plaintext = preg_replace('#&lt;!--.*?--&gt;#s', '', $plaintext); // put a space between list items (strip_tags just removes the tags). $plaintext = preg_replace('#&lt;/li&gt;#', ' &lt;/li&gt;', $plaintext); // remove all script and style tags $plaintext = preg_replace('#&lt;(script|style)\b[^&gt;]*&gt;(.*?)&lt;/(script|style)&gt;#is', "", $plaintext); // remove br tags (missed by strip_tags) // remove all remaining html $plaintext = strip_tags($plaintext); return $plaintext; } </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