Pregunta

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

¿Fue útil?

Solución

Just split it by end-of-line:

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

or if Unix, then:

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

Otros consejos

Maybe something like this?

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

This is a another solution

$lines = preg_split( '/\r\n|\r|\n/', $string );
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top