Re: preg_match
| From: | sven | Date: | Fri, 20 Jun 2003 09:31:26 +0000 |
| Subject: | Re: preg_match | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152289@lists.php.net to get a copy of this message | ||
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" <axelseaa@amadmax.com> schrieb im Newsbeitrag news:000101c336ea$3efd9840$6400a8c0@DELTA...
-----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: axelseaa@amadmax.com
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-----