0

Consider the following code

if (  stripos($a,'something1')===0 || stripos($a,'something2')===0  ) {
        return '';
}

Is there a performance benefit for using in_array or does php stops testing if first condition evaluate to true ?

user2650277
  • 6,289
  • 17
  • 63
  • 132
  • 1
    Yes PHP does stop if the first one is true during the short circuit evaluation, which PHP has – Rizier123 Jun 29 '15 at 15:49
  • @Rizier123 ...Thanks for reminding me of the term `short circuit evaluation`.Suppose that that i had like 3-7 more `stripos` in the condition , will there be any performance benefit in using in_array – user2650277 Jun 29 '15 at 16:10

1 Answers1

0

Relative to your question about performance.

As they say here, strpos is better. https://stackoverflow.com/a/21070786/4627253

Community
  • 1
  • 1
Miguel
  • 126
  • 9