我有一个从 iCal 中提取的字符串,它输出描述。我想每次都进行描述并用我需要的对象创建一个数组。他们总是遵循相同的模式。
例如我有:
Description: Trip status: Confirmed\n \n FLIGHT INFORMATION: \n \n United Airlines UA 485: \n \n \n From: Newark Liberty International (New York, USA) - TerminalC at Fri, Sep 28, 2012 16:34 (local time) \n To: Denver International (Denver, USA) at Fri, Sep 28, 2012 18:47 (local time) \n Cabin: Economy Restricted\n Duration: 04:13\n Stop(s): 0\n Aircraft: Boeing 757-200\n
进而
Description: Trip status: Confirmed\n \n FLIGHT INFORMATION: \n \n Air Canada AC 1072: \n \n \n From: Denver International (Denver, USA) at Sat, Sep 29, 2012 10:55 (local time) \n To: P Trudeau International (Montreal, Canada) at Sat, Sep 29, 2012 16:29 (local time) \n Cabin: Economy Restricted\n Duration: 03:34\n Stop(s): 0\n Aircraft: Airbus Industrie A319\n
如您所见,不同的输出遵循相同的结构,因此在理想的世界中,我想要:
$itinery[0]: Confirmed
$itinery[1]: United Airlines UA 485
$itinery[2]: Newark Liberty International (New York, USA)
一如既往的任何指导表示赞赏。
谢谢。