preg_matchtry without backslashes. $pattern = "/$search/i"; if (preg_match ($pattern, $date[$i])) { echo "$date[$i]<br />"; }
you don't need the .*? in your regex (either * or ? multiplier) as preg_match searches for any occurance (not from begin ^ or to end $). ciao SVEN "Aaron Axelsen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I am trying to code a search, and i need to get my matching expression to work right. The user can enter a value swhich is stored in the vraible $search. What the below loop needs to do, is search each entry of the array for any occurance of the $search string. If i hard code in the string it works, but not when passed as a varaible. Is there something I am missing? Do i need to convert the $search variable to soetmhing? if (preg_match ("/.*?\\\$search.*?/i",$date[$i])) { print "$date[$i]<br>"; } - --- Aaron Axelsen AIM: AAAK2 Email: [EMAIL PROTECTED] Want reliable web hosting at affordable prices? www.modevia.com Web Dev/Design Community/Zine www.developercube.com -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBPvKWA7rnDjSLw9ADEQIfGQCgwAO5ikh/RIN5OXoVkC8F4FH/YAoAoJE5 zMxHkRssHbU2Vm4svv2hId8O =DJOi -----END PGP SIGNATURE-----