Jump to content


Photo

pregmatch an ampersand


  • Please log in to reply
1 reply to this topic

#1 kiss-o-matic

kiss-o-matic
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts

Posted 12 March 2006 - 02:39 AM

I've got a button on my site that will take the entire URL, change on of the values, and make it a URL. The problem is, it takes ampersands as just that, and not '&'. I'm trying to validate the page, but this little button is preventing me from doing it, on any page that has an ampersand in the URL.

I tried this:

        
        if ( preg_match("/(.?)&(.?)/i", $whole_url) ) {
                echo 'match';
                $pat = '/(.?)&(.?)/';
                $rep = '$1' . '&' . '$2';
                $whole_url = preg_replace( $pat, $rep, $whole_url );

        }

It doesn't print match though, so it's not matching. I even tried escaping the &, but to no avail. Am I missing something here?

#2 kiss-o-matic

kiss-o-matic
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts

Posted 12 March 2006 - 03:52 AM

nevermind. I've discovered str_replace which works better.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users