Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by Alex Pliutau for Documentation for ?: in regex?

I don't know how do this with ?:, but it is easy with simple loop:

$regex = '/b(ig|all)/';$array = array(    0 => array(0 => 'big', 1 => 'ball'),    1 => array(0 => 'ig', 1 => 'all'));foreach ($array as $key => $row) {    foreach ($row as $val) {        if (!preg_match($regex, $val)) {            unset($array[$key]);        }    }}print_r($array);

Viewing all articles
Browse latest Browse all 7

Trending Articles