Computer problems,Computer help
*AX SOFT>>>Programming & Design

Multiple values in one if, php?


(php5) is it possible for me to insert more than one value into an if statement? ex.

if ($var == 1,2,3)

how can I write something like that, compressed and such? if $var is equal to 1 or 2 or 3?

Probably a better way, but what about..

if($var==1 || $var==2 || $var==3)

if($var >= 1 && <= 3)

If we're dealing with integers:

if(($var >0) && ($var < 4))

executes faster.

This would work for any data, not only numbers;

if ( in_array( $var, array(1, 2, 3 ) )

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Email form?

    ...

  • The most important differences between called top down or structured) programming?

    There are lots of similarities and overlaps, but basically the difference is this: In structured programming, the idea was that the overall flow of control of the program was laid out using a fu...

  • Php: strptime replacement?

    strftime ...

  • Getting input from a text file using c strings in c++?

    Sure, as long as you use the #include<fstream> header, and name the file you want to use as input. When you parse the data, just store it to a C-String, which as you should know is an array m...

  • Hey can anyone help me plz find....??

    Go to any picture you want and right click it chose save as, then open the file in paint and you can change it to any size you want. Just go to stretch/skew and put in how much bigger or smaller yo...

  • Does anyone know any really good open source game engines?

    There are a number of open source engines to suggest such as Ogre, Crystal Space, and Irrlicht. Torque is a great value for a commercial engine. Also, the "source of all knowledge" actu...

  • Is there easy way to....?

    Well programming language as such is not a difficult thing to learn. Where things get a little tricky are the algorithms that we have to use to implement the problem. Programming language is nothin...

  • How to make a photo look like this one ?

    They took the picture of an old picture and overlayed ginny and harry. Then they used the cut tool and made an uneven patch along the old picture layer. Seperated them, and put harry on one side ...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster