» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-17-2006, 02:02 PM
ENIGMA ENIGMA is offline
Junior Member
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ENIGMA is on a distinguished road
Default What is IN (..VALUES..) in PHP?

Just curious, in other language I can easily write:

if $something IN ('AA','AB','CD') then ...

is there that easy "IN" operator in PHP? other than writing like this:

if ($something=='AA' || $something=='AB' || ...)

-OR-

strpos('AAABCD', $something)

Thanks a million for your help -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-17-2006, 02:03 PM
zoloby zoloby is offline
OSP Starters
 
Join Date: Jul 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
zoloby is on a distinguished road
Talking

Hi dude

Not a language construct or anything of that nature. The most similar in functionality would be in_array().

Code:

# if $something IN ('AA','AB','CD') then ...
# to...
$arr= array ( 'AA' , 'AB' , 'CD' ) ;
if ( in_array ( 'something' , $arr ) )
{

}

Have a good day -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  #3  
Old 08-17-2006, 02:05 PM
sinister sinister is offline
OSP Starters
 
Join Date: Jul 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sinister is on a distinguished road
Default

Quote:
Originally Posted by ENIGMA
if ($something=='AA' || $something=='AB' || ...)

-OR-

strpos('AAABCD', $something)
Those two notation are NOT equivalent, Code:

<?php

$something = 'AAA';

if ($something=='AA' || $something=='AB')
{
echo '<li>Found using method 1</li>';
}
else
{
echo '<li>Not found using method 1</li>';
}

if (strpos('AAABCD', $something) !== false)
{
echo '<li>Found using method 2</li>';
} < -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
i can help with php averagejoe Advertise Programming Services 1 02-25-2007 03:48 AM
Is PHP loosing out to .NET? garcia PHP Programming and Tips 1 08-10-2006 01:44 PM
Recompiling PHP, Fedora 4 jhingalala PHP Programming and Tips 1 07-17-2006 01:47 PM
Getting MySQL & PHP to communicate JCH MySQL Forums 0 05-29-2006 01:52 PM
Counting Values in Array johny PHP Programming and Tips 1 12-07-2005 07:00 AM


All times are GMT. The time now is 04:39 AM.