/[LeafOK_CVS]/fenglin/lib/str_process.inc.php
ViewVC logotype

Diff of /fenglin/lib/str_process.inc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 by sysadm, Fri Jun 25 08:26:49 2004 UTC Revision 1.3 by sysadm, Fri Jun 25 08:58:04 2004 UTC
# Line 7  function split_line($str,$pre="",$width= Line 7  function split_line($str,$pre="",$width=
7          $len = strlen($str);          $len = strlen($str);
8    
9          $hz_ok = true;          $hz_ok = true;
10            $en_ok = true;
11                    
12          if ($width<=0)          if ($width<=0)
13                  return $str;                  return $str;
# Line 15  function split_line($str,$pre="",$width= Line 16  function split_line($str,$pre="",$width=
16          $line_count = strlen($line);          $line_count = strlen($line);
17          for($i=0;$i<$len;$i++)          for($i=0;$i<$len;$i++)
18          {          {
                 if ($line_count >= $width && $hz_ok)  
                 {  
                         $lines[$lines_count++] = $line;  
                         $line = $pre;  
                         $line_count = strlen($line);  
                 }  
19                  $line.=$str[$i];                  $line.=$str[$i];
20                  $line_count++;                  $line_count++;
21                  if (ord($str[$i])>127)                  if (ord($str[$i])>127)
22                    {
23                          $hz_ok = (!$hz_ok);                          $hz_ok = (!$hz_ok);
24                            $en_ok = true;
25                    }
26                  if (ord($str[$i])<=127)                  if (ord($str[$i])<=127)
27                    {
28                          $hz_ok = true;                          $hz_ok = true;
29                            if ($str[$i] == " ")
30                            {
31                                    $en_ok = true;
32                            }
33                            else
34                            {
35                                    $en_ok = false;
36                            }
37                    }
38                    if ($line_count >= $width && $hz_ok && $en_ok)
39                    {
40                            $lines[$lines_count++] = $line;
41                            $line = $pre;
42                            $line_count = strlen($line);
43                    }
44          }          }
45          $lines[$lines_count++] = $line;          $lines[$lines_count++] = $line;
46    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1