i have a piece of code that collects url from a database then i con call this in another file but i would like to replace the text after 20 letters the several dots here is the code //print_r($row); $info['results'][$num]['number']=$num+1; $info['results'][$num]['url']=$row[0]; $info['results'][$num]['title']=$row[1]; $info['results'][$num]['type']=$row[2]; if($row[3]) $info['results'][$num]['filesize']=", FileSize: ".$row[3]; //number_format($row[3],0,"."," "); else $info['results'][$num]['filesize']="<font color=\"grey\"> Not Checked</font>"; if($row[5]) { if(strpos($row[5],"http://")!==false) $info['results'][$num]['source']=" <a href=\"".$row[5]."\" target=\"_blank\"><img src=\"templates/padlock.gif\"style=\"border-style: none\" alt=\"Source\" width=\"64\" height=\"16\" /></a>"; else $info['results'][$num]['source']=" (<a href=\"http://".$row[5]."\" target=\"_blank\">source</a>)"; } else $info['results'][$num]['source']=""; <-- think its this line $info['results'][$num]['relevance']=$row[4]; $substr=strtolower(substr($info['results'][$num]['url'],-20)); foreach($icons as $key => $value) PHP:
change this $substr=strtolower(substr($info['results'][$num]['url'],-20)); to $substr=strtolower(substr($info['results'][$num]['url'],20));
For sanities sakes, I'll just use placeholders... // our string $string = $myarray['location1']; // start at position 0 and continue until position 20 $string = substr($string, 0, 20); // lower everything $string = strtolower($string); // all in one - harder to debug $string = strtolower(substr($string, 0, 20))."..."; Code (markup):
<style type="text/css"> .mydiv { height: 20px; width: 150px; overflow:hidden; text-overflow: ellipse; } </style> <div class="mydiv">This is long text. This is long text. This is long text. This is long text.</div> Code (markup):