【发布时间】:2012-09-25 13:35:49
【问题描述】:
下面的脚本显示了一个文本文件中的搜索字符串,我的文本文件的内容如下:
60, 1, 1, 188, pdgje5566
60、1、1、188、pdgje5565
if(!empty($extTxId)){
$searchfor = $extTxId;
$matches = array();
$handle = @fopen($file, "r");
if ($handle)
{
while (!feof($handle))
{
$buffer = fgets($handle);
if(strpos($buffer, $searchfor) !== FALSE)
$matches[] = $buffer;
}
fclose($handle);
}
print_r($matches);
输出为
数组 ([0] => 60, 1, 1, 188, ppje5566)
但是我想分解由逗号(,)分隔的数据并存储到变量中,无论如何都要这样做吗?
谢谢。
【问题讨论】:
-
嗯,你的意思是
$tokens = explode(",", $str);?该函数的字面意思是explode。