$str1='sid1|text1|text2|text3|tex4';
$str2='sid2|text1|text2|text3|tex4';
$arr1=explode('|',$str1);
$arr2=explode('|',$str2);
然后:
$str1[0]就是sid1
$str1[1~4]就是text1~text4
首先分割换行符,
$text = file_get_contents($file);
$aLine = explode("\n",$text);
foreach($aLine as $v){
$arr = explode(‘|’,$v);
print_r($arr);exit;//输出看看结构
}
$str='
sid1|text1|text2|text3|tex4
sid2|text1|text2|text3|tex4
';
preg_match('#(sid1[^\s]+)#isU',$str,$sid);
print_r($sid);