Skip to content

Мэдээг таслаж харуулах

November 1, 2006

Вэбсофт Монгол ХХК-ын вэб боловсруулах программын эх кодыг та бүхэнд танилцуулж байнаМэдээ нь HTML мэдээлэл ордог учираас HTML таг орсон байвал хаах зэрэг үйлдэл оруулав.
function text_cut ( $str, $len, $flag ) {

  $str = ereg_replace(“<tr>”,”&nbsp;”,”$str”);
  $str = ereg_replace(“<td>”,”&nbsp;”,”$str”);
  $str = ereg_replace(“</tr>”,”&nbsp;”,”$str”);
  $str = ereg_replace(“</td>”,”&nbsp;”,”$str”);
  $str = str_replace(“</table>”,”<br>”,”$str”);
  $str = substr($str,0,$len+200);
  $str=replaceBr($str);
  //echo $str;
  if ( $flag == 1 AND eregi ( “<table”, $str ) ){
    
    $strpos1 = strpos ( $str, ‘<table’ );
    $temp=$str;
    $len1 =$len+200;
    $strpos2 = -1;
    while ( $strpos2 < $strpos1 ){
     $strpos2 = strpos ( $temp, “>” );
     $temp = substr ( $temp, $strpos1,$len1);
    }
    //echo ” strpos1 = $strpos1 strpos2 = $strpos2 <br />”;
    $str1 = “”;
    $str2 = “”;
     if ( $strpos2 > $strpos1 ) {
      if ( $strpos1 >=1 ) {
     $str1 = substr ( $str, 0, $strpos1 );
     }
      $str2 = substr ( $str, $strpos2 + 7 , strlen ( $str ) );
     $str = “$str1$str2″;
    }
   }  
  
 return isStrrpos ( $str, $len ) ? $str : substr ( $str, 0, strrpos ( substr ( $str, 0, $len ), ” ” ) ) .” …”;
 }

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: