如果我有这个长字符串:
WAITLIST, 91630, ACCY 2001 , 10, Intro Financial Accounting, 3.00, Zou, Y, DUQUES 251, TR09:35AM - 10:50AM, 01/13/14 - 04/28/14 , , WAITLIST, 90003, ACCY 2001 , 11, Intro Financial Accounting, 3.00, Zou, Y, DUQUES 254, TR11:10AM - 12:25PM, 01/13/14 - 04/28/14 , , OPEN, 91212, ACCY 2001 , 12, Intro Financial Accounting, 3.00, Zou, Y, 1957 E B12, TR02:20PM - 03:35PM, 01/13/14 - 04/28/14 , , WAITLIST, 90004, ACCY 2002 , 10, Intro Managerial Accounting, 3.00, Linsley, C, FNGR 222, TR11:10AM - 12:25PM, 01/13/14 - 04/28/14 , ,
我想搜索“,”并在每次出现后直接添加一个换行符,所以我的长字符串如下所示:
WAITLIST 91630 ACCY 2001 10 Intro Financial Accounting 3.00 Zou, Y DUQUES 251 TR09:35AM - 10:50AM 01/13/14 - 04/28/14
WAITLIST 90003 ACCY 2001 11 Intro Financial Accounting 3.00 Zou, Y DUQUES 254 TR11:10AM - 12:25PM 01/13/14 - 04/28/14
OPEN 91212 ACCY 2001 12 Intro Financial Accounting 3.00 Zou, Y 1957 E B12 TR02:20PM - 03:35PM 01/13/14 - 04/28/14
ETC....
我在想我可以使用 stripos 记录每个“,”的位置并将其添加到数组中。然后我可以使用 for 循环遍历数组并在每个双逗号的位置后附加一个 '<br>'。那行得通吗?干杯!