i have a litte problem with wrote correct reg exp, i have a string
2013-01-11 17:38:02.137759 some text leater
or
11 Jan 17:38:02 some text leater
so i wrote a reg exp
(?:(?:(?:\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(?:\.\d+)?)\s(?:[^\s]+)\s(?:.\d+.)?\s?))?((?:(\d{4}-\d{2}-\d{2})\s\d{2}:\d{2}:\d{2}(?:\.\d+)?)|(?:(\w{3}\s+\d+)\s\d{2}:\d{2}:\d{2}))
the example result is:
Array
(
[0] => Array
(
[0] => Jan 11 17:38:02
)
[1] => Array
(
[0] => Jan 11 17:38:02
)
[2] => Array
(
[0] =>
)
[3] => Array
(
[0] => Jan 11
)
)
or
Array
(
[0] => Array
(
[0] => 2013-01-11 17:38:02.137759
)
[1] => Array
(
[0] => 2013-01-11 17:38:02.137759
)
[2] => Array
(
[0] => 2013-01-11
)
[3] => Array
(
[0] =>
)
)
the problem is the result i wanna skip a empty field result's how can i do that?
Thanks for help
The simplest way would just be to use array_filter
on the result:
array_filter($array, function ($piece) { return array_filter($piece); });