Gerardlc Gerardlc - 1 year ago 112
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:


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 Source

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


This will work as shown here:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download