How can I shorten this PHP if statement?

前端 未结 2 1499
再見小時候
再見小時候 2021-01-25 02:04

I have an if statement, and I need to compare a single string with many different options. The code I post below shows what I mean pretty clear. I know 2 ways of doing this, but

相关标签:
2条回答
  • 2021-01-25 02:20

    http://php.net/manual/en/function.in-array.php

    $centered = array ("contact","report","new");
    if(in_array($Url[0], $centered)) {
        //Do something
    }
    
    0 讨论(0)
  • 2021-01-25 02:20

    You want in_array().

    0 讨论(0)
提交回复
热议问题