vendredi 31 juillet 2015

PHP - Checking up on string with regex and push to array

I have two variables as follows:

$string1 = '/test/10/25';
$string2 = '/test/[0-9]+/[0-9]+

Is it possible to make PHP compare these two strings and push the actual ID's (10 and 25) into an array like so by using the regex as some sort of guidance?

Array
(
    [0] => 10
    [1] => 25
)

I tried playing around with preg_match() but this just puts everything into the same array key.

Aucun commentaire:

Enregistrer un commentaire