warning in preg_match

There is this code:

preg_match("#*;$dep;*#", $temp[3]);

$dep is a regular int number, $temp[3] is a string consisting of ;13;1;2;6;88;

The interpreter gives a strange warning:

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1

Help me understand

Answer 1, authority 100%

The * quantifier requires something to precede it, so it says “nothing to repeat at offset 1”.

Leave a reply

Please enter your comment!
Please enter your name here