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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chris dot walsh at pni dot com
New email:
PHP Version: OS:

 

 [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: Wed Jun 26 14:01:32 2024 UTC