PHP regex problem
I have two variables, $cityd, and $city.
I'm trying to see if the string $city (a single or multiple words) is located within $cityd.
Here is the code I'm using now
if(preg_match ("/\\\$cityd/i", $city)) {
The problem with this, is that it's not being as flexible as I'd like it to be. If "vegas" is entered for $city, then it won't match "Las Vegas". I don't know if preg_match is the best function to use for this, so if anyone has a better idea of going about this, please let me know.
nike_guy_man posted this at 21:53 — 2nd February 2003.
They have: 840 posts
Joined: Sep 2000
if (eregi("$city", $cityd)) {
http://www.php.net/manual/en/function.eregi.php
zollet posted this at 22:17 — 2nd February 2003.
He has: 1,016 posts
Joined: May 2002
Why do you have all the backslashes? with preg_match() it would be..
if(preg_match("/$city/i", $cityd)) {
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.