php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27225 in_var function
Submitted: 2004-02-11 17:10 UTC Modified: 2004-02-11 17:35 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: chris dot walsh at pni dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.5RC2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
24 + 35 = ?
Subscribe to this entry?

 
 [2004-02-11 17:10 UTC] chris dot walsh at pni dot com
Description:
------------
Looking for a comparison operator/function to similar to the mysql "in" function.

This could be used to replace long if statments:
if($a=="b" || $a=="c" || $a=="d")

something like
if(in($a,"b","c","d"))
or
if($a=="b"||"c"||"d")
or
if($a|="b","c","d")



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-11 17:30 UTC] derick@php.net
if (in_array("a", array("a", "b", "c"))) works fine for this :)
 [2004-02-11 17:35 UTC] chris dot walsh at pni dot com
That works... as does an ereg() call, but it seems kind of clunky to have to create an array and then call an array function (or use a pattern match), when it would be more efficient to have a function/operator that deals directly with the string.

Just my two cents...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 29 08:01:30 2024 UTC