简体   繁体   中英

Confusing with a php variable issue

In the below code, after the preg_match , $videoinfo['video']['rendering'] most definitely equals "Progressive".

So, I am expecting the final echo to output "Rendering: Progressive Scan".

However, it doesn't. It outputs "Rendering: Progressive" Am I missing something obvious here?

Thanks for your help!

if(preg_match("/^Video Field Order\s+:(.*)$/im",$output,$matches)){
    $videoinfo['video']['rendering'] = $matches[1];
    if($videoinfo['video']['rendering'] == "Progressive"){              
        $videoinfo['video']['rendering'] = 'Progressive Scan';                      
    }               
    echo("Rendering: " . $videoinfo['video']['rendering']);
}

You do this

echo("Rendering: " . $videoinfo['video']['rendering']);

and you say that It outputs "Rendering: Progressive."

That means that $videoinfo['video']['rendering'] contains the string Progressive. . Mind the dot!

So it has 1 character extra (the dot), and that's why your equals doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM