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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Jun 25 08:26:49 2004 UTC (21 years, 8 months ago) by sysadm
Branch: MAIN
Changes since 1.1: +3 -3 lines
Modify declaration of str_process() in str_process.inc.php

1 <?
2
3 function split_line($str,$pre="",$width=75)
4 {
5 $lines = array();
6 $lines_count = 0;
7 $len = strlen($str);
8
9 $hz_ok = true;
10
11 if ($width<=0)
12 return $str;
13
14 $line = $pre;
15 $line_count = strlen($line);
16 for($i=0;$i<$len;$i++)
17 {
18 if ($line_count >= $width && $hz_ok)
19 {
20 $lines[$lines_count++] = $line;
21 $line = $pre;
22 $line_count = strlen($line);
23 }
24 $line.=$str[$i];
25 $line_count++;
26 if (ord($str[$i])>127)
27 $hz_ok = (!$hz_ok);
28 if (ord($str[$i])<=127)
29 $hz_ok = true;
30 }
31 $lines[$lines_count++] = $line;
32
33 $result = "";
34 for($i=0;$i<$lines_count;$i++)
35 {
36 $result.=($lines[$i]."\r\n");
37 }
38 return $result;
39 }
40
41 function str_process($str,$pre="",$width=75)
42 {
43 $result = "";
44
45 $lines = explode("\n",str_replace("\r\n","\n",$str));
46
47 foreach($lines as $line)
48 {
49 $result .= split_line($line,$pre,$width);
50 }
51
52 return $result;
53 }
54
55 ?>

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