문제

I have a string like so:

diverr_daily_report_2013-10-21_02:00:48_diverr_users_20_10_2013csv.csv
diverr_daily_report_2013-10-22_09:10:02_diverr_users_21_10_2013csv.csv

and i want to split it into elements.

output should look like:

[0]diverr_daily_report_2013-10-21_02:00:48_diverr_users_20_10_2013csv.csv
[1]diverr_daily_report_2013-10-22_09:10:02_diverr_users_21_10_2013csv.csv    

i was thinking to use the first and last word as a needle(they never chnage) : "diverr,csv"

what is a good way of doing this?
thanks

도움이 되었습니까?

해결책

Just split it by end-of-line:

$result = explode("\r\n", $your_string);

or if Unix, then:

$result = explode("\n", $your_string);

다른 팁

Maybe something like this?

$array = explode("\n", $string);

This is a another solution

$lines = preg_split( '/\r\n|\r|\n/', $string );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top