ホームページ  >  記事  >  バックエンド開発  >  PHP テキスト操作クラス_PHP チュートリアル

PHP テキスト操作クラス_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-21 16:00:521216ブラウズ

コードをコピーします コードは次のとおりです:
< PHP ctbclass {var $ index; Readfile() の戻りで、データ行を 1 次元配列に変換します
Function Make_array ($ LINE) {
$ array = Explode ("x0e", $ line);
Return $ array
; // 1 行のデータを 1 次元配列に変換します
$array を返す
}文 // データ ファイルに返される行数
Function getlines () {
$ f = file ($ this- & gt; file) ) ; $this->get() ; prev_line(){;
flock($ f、lock_sh); = 0; $ i< = $ this-> $ i ++){"function read_file(){line = file($ this-> file);
array_push($ tmpline);

); If ($check_n==1) fputs($f,"n") ; // 先頭に記録したデータを 1 行挿入します。 r ");
$ f = fopen($ this-> file、" w ");

= Inprode( "x0e"、$ update_array); f=fopen($this->file,"w"); fclose($f);

= Inprode( "x0e"、$ update_array); ($ this-> ファイル, "w");
FLOCK ($ f, $newfile);
> file) ; put($f ,$newファイル);" "; & gt; ファイル, "r");
While ($ line = fgets ($ f, 1024) )) {
$ tmpline = Explode ("x0e", $ line) ; $ tmpline [$ column]!= $ query_string){$ this-> $ tlines = file($ this> file);M $ get_max_value = max ($ get_value);
Return $ get_max_value;
}
// データ ファイルにクエリ対象の $ query_string が含まれているかどうかを示し、select ( $ COLUMN, $ Query_String) 関数に戻ります。 $ $ tline $>

yです - > file))// データファイルのフィールドにクエリ対象の $ Query_String が含まれているかどうかを確認し、最初のデータを 1 次元配列で返します
Function Select_line ($ colorn, $ query_string) {
$ TLINE = $ this- & gt; );
Foreach ($ TLINE As $ TMPLINE) {
$ LINE = $ MAKE_ARAY ($ TMPLINE); ;   
// select next/prev line(next_prev ==> 1/next, 2/prev) by cx
関数 select_next_prev_line($column, $query_string, $next_prev) {
$tline = $this->read_file() ;   
$line_key_end = count($tline) - 1;   
$line_key = -1;   
foreach ($tline as $tmpLine) {
$line_key++;   
$line = $this->make_array($tmpLine);   
if ($next_prev == 1) { // 次?   
if ($line[$column] == $query_string) {
if ($line_key == 0) {
Return 0;   
}  else {
$line_key_up = $line_key - 1;   
return $up_line;   
} else {
$up_line = $line;   
}
} elseif ($next_prev == 2) { // 前?   
if ($line[$column] == $query_string) {
if ($line_key == $line_key_end) {
0 を返します。   
}  else {
$line_key_down = $line_key + 1;   
休憩。   
}
else {
Return 0;   
}
}
$down_line = $this->make_ar ray($tline[$line_key_down]);   
戻り $down_line;   
}


}
?> 

http://www.bkjia.com/PHPjc/317060.htmlwww.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/317060.html技術記事复制代码代码如下: ?php classCtbClass{ var$file;変数$インデックス; //建立一文件并書き込み入 functionnull_write($new) { $f=fopen($this-file,"w");群れ($f,LOCK_EX);フプ...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。