if statement with multiple or condition

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 ?

-------------Problems Reply------------

Relative to your question about performance.

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

Category:php Views:7 Time:2019-03-03

Related post

  • How to translate SQL statement with multiple join conditions based on subquery to LINQ 2011-07-13

    This might be one of those situations where plain SQL commands are better than LINQ. Here's a simplified version of the SQL statement I'm trying to translate: SELECT * FROM IDTable AS idt INNER JOIN NameTable AS nt ON nt.IDTableID=idt.Id AND nt.Id= (

  • If Statements with multiple logic conditions 2014-01-08

    I'm trying to create a commission cell in a spreadsheet where if cell B54 is between 20% to 29% the commission is 2% of cell C55 , 3% if B54 is between 30% to 39%, and 4% if B54 is greater than 40%. The formula I have so far only works if B54 is betw

  • Does a javascript if statement with multiple conditions test all of them? 2009-12-18

    In javascript, when using an if statement with multiple conditions to test for, does javascript test them all regardless, or will it bail before testing them all if it's already false? For example: a = 1 b = 2 c = 1 if (a==1 && b==1 &

  • If Statement With Multiple Lines 2011-11-28

    I have an if statement with multiple conditions. I cannot see them all in a single window view. Is there a way to separate them on different lines or do they have to be written all in one line? --------------Solutions------------- The VBA line-contin

  • SQL Statement with multiple SET's and WHERE's 2011-06-22

    I am wondering if this is a valid query: UPDATE table SET ID = 111111259 WHERE ID = 2555 AND SET ID = 111111261 WHERE ID = 2724 AND SET ID = 111111263 WHERE ID = 2021 AND SET ID = 111111264 WHERE ID = 2017 --------------Solutions------------- NO! You

  • Statement with multiple fork() s 2012-03-14

    The child process begins executing at the exact point where the last one left off - after the fork statement. What if the statement contains multiple fork()s like the conditional expression like the following. Where exactly program execution starts f

  • MYSQL CASE THEN statement with multiple values 2012-04-14

    I am trying go select multiple values with CASE statement. I noticed we cannot do CASE WHEN wall.type="bk" THEN books.id1,books.id2, // and so on END as column_1, Is there a way to do THEN with multiple columns or do we need to simply write a bunch o

  • How to join with multiple (OR) conditions in LINQ to SQL? 2010-07-08

    How would I perform this SQL query Select Distinct s.* from #ScopeIDs x Join Scopes s on s.ScopeID=x.ScopeID or x.ScopeID is null in LINQ to SQL? (This query would return all Scopes whose ScopeID is present in #ScopeIDs, unless one of the entries in

  • SQL Retrieving values from a statement with multiple selects 2011-06-24

    I have this SQL: SELECT count (1) FROM users AS total_drafts WHERE version_replace = @sid SELECT count (1) AS unpublished_drafts FROM users WHERE version_replace = @sid AND moderated = 0 SELECT * FROM users WHERE id = @sid ORDER By ID DESC Which appe

  • SQLAlchemy: SQL Expression with multiple where conditions 2012-02-01

    I'm having difficulties writing what should be a simple SQL update statement in SQLAlchemy Core. However, I can't find any documentation, examples or tutorials that show how to combine multiple where conditions. I'm sure it's there - just can't find

  • perl, dbi with sql statement with a like condition 2010-07-21

    in my code i must do a simple sql query with a like condition. i've do in this way my $out = "/Users/zero/out.log"; my $filename = "/Users/zero/data.txt"; my $dbh = DBI->connect("DBI:Oracle:sid=$sid;host=$host;port=$port", $user, $pwd) or die "Cou

  • CASE IN statement with multiple values 2011-09-16

    Is there a way to make a CASE statement with an IN clause? SELECT CASE c.Number IN ('1121231','31242323') THEN 1 IN ('234523','2342423') THEN 2 END AS Test FROM tblClient c --------------Solutions------------- Yes. You need to use the "Searched" form

  • Best way to format if statement with multiple conditions 2008-10-31

    If you want to some code to execute based on two or more conditions which is the best way to format that if statement ? first example:- if(ConditionOne && ConditionTwo && ConditionThree) { Code to execute } Second example:- if(Conditi

  • Quick question on If statements with multiple conditions 2011-02-17

    Possible Duplicate: && (AND) and || (OR) in Java IF statements This is a question I should have probably known the answer to years ago but if I am writing an if statement in Java that has something like if(x != null && y == null &

  • Use of If statement with multiple conditions 2011-06-10

    I have written the following code which is basically supposed colour some boxes accordingly. Whenever i run this code, it runs the first case i.e. even when some other case is required to be selected. here is the code. Sub Macro_quaterly() If Sheet2.

  • How do I write an IF statement with multiple conditions on the same line in Bash? 2011-07-19

    I'm writing a script right now in Bash that will execute two SQL queries and analyze that queried data. One of the command line inputs takes in an environment variable, which can be one of three values. If it's not one of those values, the script dis

  • PHP If Statement with Multiple Conditions 2011-04-08

    I have a variable$var. I want echo "true" if $var has got either of the following values abc, def, hij, klm, or nop. Is there any way to do this with a single statement like && statement?? --------------Solutions------------- if($var == "abc"

  • Find statement with multiple conditions in one cell 2014-04-03

    Cell A1 has a string of two digit number codes and in cell B1 find if a list of 17 different codes are in the string in cell A1. Just need to return Yes or No if any of the 17 different codes are contain in cell A1. New to the Community. Thanks Z9417

  • If statement with multiple text arguments inside range 2014-12-15

    I am trying to find the average of certain values inside a column according to the adjacent (previous column) text value they are paired with. In the following case for example, I would like to find the average of the results scored by the west coast

  • if statement with multiple ORs 2015-01-30

    I have the following If statement in a private sub and keep getting a Run-Time Error '13' Type Mismatch. If Me![VMountingP] Like "F03" Or "F04" Or "F05" Or "F07" Or "F10" Or "F12" Or "F14" Or "F16" Then I have taken out the "or"s and just left the fi

  • LINQ to SQL - Left Outer Join with multiple join conditions 2009-07-14

    I have the following SQL, which I am trying to translate to LINQ: SELECT f.value FROM period as p LEFT OUTER JOIN facts AS f ON p.id = f.periodid AND f.otherid = 17 WHERE p.companyid = 100 I have seen the typical implementation of the left outer join

  • Own function with multiple "if" conditions in jquery 2010-09-21

    Actually I whant to feed a variable "var xy" with diverent heights in dependence of more than one "if" condition. The best way to do this, is to create a custom function,isn't it? Well, I don't know how to do that. I've done something like this to ge

  • Ruby case statement with multiple variables using an Array 2011-01-29

    I'd like to compare multiple variables for a case statement, and am currently thinking overriding the case equals operator (===) for Array is the best way to do it. Is this the best way? Here is an example use case: def deposit_apr deposit,apr # depo

  • Ruby case statements with multiple variables 2011-02-01

    Ruby has a fairly powerful case..when..else construct for when you need to match criteria against a single variable. What is the "canonical" way to match criteria against multiple variables without simply nesting case statements? Wrapping multiple va

  • SHOW TABLES statement with multiple LIKE values 2011-04-10

    mysql> SHOW TABLES like 'cms'; +-------------------------+ | Tables_in_tianyan (cms) | +-------------------------+ | cms | +-------------------------+ 1 row in set (0.00 sec) Result mysql> SHOW TABLES like 'cms' or like 'role'; ERROR 1064 (4200

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.135 (s). 11 q(s)