John Mark
John Mark

Reputation: 37

Replace old eregi function PHP

I'm having problems to fix this old PHP eregi funxtion becouse it uses IN parameter.. It's script for captcha generation class_log.php from Matthieu MARY

old code:

$sMotif = "--$sIN ([a-zA-Z0-9]{3,4},)*([a-zA-Z0-9]{3,4}){1}";
if ((eregi("$sMotif ",$this->sParam))||(eregi("$sMotif$",$this->sParam))){
    $this->aParam['bExtension'] = TRUE;
    $this->aParam['aExtension'] = $this->_PARAM_get_extension($sIN);
    $this->aParam['inExtension'] = ($sIN=='e');
    $this->aParam['iParameters']++;
}

I try with this, but not sure is it correct?

$sMotif = "/--$sIN ([a-zA-Z0-9]{3,4},)*([a-zA-Z0-9]{3,4}){1}/i";
if ((preg_match("$sMotif ",$this->sParam))||(eregi("$sMotif$",$this->sParam))){
    $this->aParam['bExtension'] = TRUE;
    $this->aParam['aExtension'] = $this->_PARAM_get_extension($sIN);
    $this->aParam['inExtension'] = ($sIN=='e');
    $this->aParam['iParameters']++;
}

tnx

Upvotes: 0

Views: 85

Answers (1)

Toto
Toto

Reputation: 91415

Here is the way I'd do the job:

$sMotif = "/--$sIN ([a-zA-Z0-9]{3,4},)*([a-zA-Z0-9]{3,4}) ?/";
if ( preg_match($sMotif,$this->sParam)) {

Upvotes: 1

Related Questions