Gerardlc Gerardlc - 1 month ago 16
PHP Question

PHP regular expresion hours

Hi i have this regular expression in php:

$programacion_array = preg_split("/(([0-9]{2}):([0-9]{2}))/",$html, -1, PREG_SPLIT_DELIM_CAPTURE);


I want to split a text by finding the hours of the programs, sample text:

asdf06:20Programold07:20Programnew

But my regular expression is returning me this:

[1] => 06:20 [2] => 06 [3] => 20 [4] => Programold


I don't see what I am missing.

Answer

Try getting rid of the inner match groups, e.g. use just:

/([0-9]{2}:[0-9]{2})/

This will work as shown here: http://ideone.com/u44OIt