> Sorry to repost this, but I haven't found a solution
> and it's still nagging me. Maybe some of you can come
> up with something I can't. Here was my original post:
> I've made myself an <INPUT TYPE="HIDDEN"> tag that
> contains in the value attribute a list of
> comma-delimited numbers. I need to find if a certain
> number is in these tags (and each file contains one
> tag). I need an ereg statement that will let me search
> these lines to see if a number exists, obviously in
> the beginning or the end or the middle or if it's the
> only number in the list. So, say I need #1, I need to
> grep each file to find if 1 is in its INPUT
> TYPE="HIDDEN" list. Here's what I mean (searching for
> number 1):
> <INPUT TYPE = "HIDDEN" NAME = "numbers" VALUE =
> "1,2,3,4,5">   //beginning
> <INPUT TYPE = "HIDDEN" NAME = "numbers" VALUE =
> "0,1,2,3,4,5">   //middle
> <INPUT TYPE = "HIDDEN" NAME = "numbers" VALUE =
> "5,4,3,2,1">   //end
> <INPUT TYPE = "HIDDEN" NAME = "numbers" VALUE = "1">
> //only
> I can't grab all the tags and search for it in PHP
> (there would be too many tags to parse through and I'd
> rather let the OS handle that). I need to do this at
> the operating system level. Does anybody yet have a
> solution? I *know* it's possible, but I can't get it
> and I've been working on it for days now. This is one
> of those really annoying bugs that really grates on a programmer.

Well, one way without regex would be to explode() numbers on a comma and
use in_array() to see if you're value exists.

$ar = explode(',',$_GET['numbers']);
{ //number is present; }
{ //number is not present; }

With regex, maybe something like this?

{ //number is present; }
{ //number is not present; }

That should look for your number, preceded by either the beginning of
the string or a comma and followed by either a comma or the end of the

Let me know if that works. 

---John Holmes...

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to