douzhan8652 2011-05-30 12:18
浏览 230
已采纳

从文本文件PHP中提取一行

I Have a text file and want to parse it with PHP

any one has any idea how can I get IMPATTO LTD

IMPATTO LTD                               ZAHLUNG:       A

from the line above ?

I was thinking maybe regex but there is no uniform way of extracting it.. I guess the best is an expression that will get me the text until the Z from Zahlung.. Is this possible ?

By the way the first words can be of variable length...

  • 写回答

5条回答 默认 最新

  • dsdf64562672 2011-05-30 12:21
    关注
    $string = null;
    $itms = explode('ZAHLUNG', $line);
    if(is_array($itms) AND isset($itms[0])) {
        $string = trim($itms[0]);
    }
    
    echo $string; // IMPATTO LTD
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥100 数字取证课程 关于FAT文件系统的操作
  • ¥15 如何使用js实现打印时每页设置统一的标题
  • ¥15 安装TIA PortalV15.1报错
  • ¥15 能把水桶搬到饮水机的机械设计
  • ¥15 Android Studio中如何把H5逻辑放在Assets 文件夹中以实现将h5代码打包为apk
  • ¥15 使用小程序wx.createWebAudioContext()开发节拍器
  • ¥15 关于#爬虫#的问题:请问HMDB代谢物爬虫的那个工具可以提供一下吗
  • ¥15 vue3+electron打包获取本地视频属性,文件夹里面有ffprobe.exe 文件还会报错这是什么原因呢?
  • ¥20 用51单片机控制急停。
  • ¥15 孟德尔随机化结果不一致