Hello i am not sure if there is something like this in PHP what i want is a variable which can mean any variable as $anything=you and may be =playingfootball or even =ieieieieidd example: if (eregi('AAAA'.$anything.'BBBB', $text)) { do something here; } as $anything may equal to anything (132,hello,abc123,...etc) or even equals nothing and the if statement returns true if the $text="AAAABBBB" or $text="AAAA123BBBB" or $text="AAAAhelloBBBB" ..etc i hope you understood what i mean i hope that someone can give me an answer Thanks Cheers Adel
Err... I'll take a wild guess and point you to the preg_match() manual page, which I think is what you want. After re-reading a couple of times, give this a try: if (preg_match('~AAAA.*BBBB~s', $text)) { // Do something } PHP:
or you could just try this : $anything=array("you","me","someThing"); foreach($anything as $value) if (eregi('AAAA'.$value.'BBBB', $text)){ // do something } PHP:
nico_swd is the most right, but to keep you in the EREGI function, here's my 2 cents: if (eregi('AAAA(.*)BBBB', $text)) { //do something here; } PHP: If you want to make sure they actually have something between the As and Bs, change the * to + * means zero or more + means one or more ? means one or none . means ANY character Don't worry about the parenthesis. It will not require them to have it in the string. It is placing a sub-match string inside the other string (it makes it look cleaner, to me anyways).