2013-10-15 119 views
0

我想在大型文本内容中搜索关键字并输出此行。 我的示例文本如下:为了PHP搜索关键字和输出此行关键字是

HSPICE模拟方法的所提出的基于RTD-纳米架构的nestlist通过使用前面提到的表示方法来验证 一个的图像的功能的候选。

分类和主题描述:C.5.4 [计算机系统实现]:VSLI系统

一般条款:设计 附加关键词和短语:VLSI,量化,色彩提取,彩色图像处理,resonant-

隧道二极管(一个或多个),细胞神经网络

ACM参考格式:

最后,我想只输出“一般术语:设计附加关键词和短语:VLSI,量化,颜色提取,彩色图像处理,谐振 - “通过搜索关键词”一般术语“。我如何在PHP中获得这个结果?对于整个文本,让它为$ content,并且$ key =“一般条款”;

+0

http://stackoverflow.com/questions/9721952/search-string-and-return-line-php – Scuzzy

回答

0

你想用正则表达式 - http://www.php.net/manual/en/function.preg-match.php

$search = 'General Terms:'; 

$pattern = '/'.$search.'(.)+/'; 

$content = 'HSPICE simulation methods for the nestlist of the proposed RTD-based nanoarchitecture in order to verify a candidate of image functions by using the afore-mentioned representation methods. 

Categories and Subject Descriptors: C.5.4 [Computer System Implementation]: VSLI Systems 

General Terms: Design Additional Key Words and Phrases: VLSI, quantization, color extraction, color image processing, resonant- 

tunneling diode(s), cellular neural network'; 

preg_match($pattern, $content, $out); 
$out[0] = str_replace($search, '', $out[0]); 
print_r($out); 
// Array ([0] => Design Additional Key Words and Phrases: VLSI, quantization, color extraction, color image processing, resonant- [1] =>)