Update to eregi() resulting from deprecation

117 Views Asked by At

I have to update a line of code that is deprecated as a result of going from PHP 5.2.x to 5.3.x

The code line is:

if (eregi('Itemid=[0-9]+', $string) === false) {

Does anyone know what the new preg_match() arguments should be converted too?

Thanks

2

There are 2 best solutions below

0
On BEST ANSWER
if( !preg_match( '/Itemid=[0-9]+/i', $string ) ) {

}
0
On
if ( !preg_match('/Itemid=[0-9]+/i', $string)) {

but maybe what is really needed is

if ( !preg_match('/^Itemid=[0-9]+$/i', trim($string))) {