preg_match search using a variable ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ben

    preg_match search using a variable ?

    Hi,

    I've been tryin to use preg_match to search through a string. But it
    doesn't seem to function with a variable as the search string. I've
    tried many variations, but I'm not sure how to do it.


    $data =
    file_get_conten ts("http://cgi.ebay.co.uk/ws/eBayISAPI.dll?V iewItem&item=$i number");
    if(preg_match('/\$'.$susername. '\./', $data)){
    print("
    Sellers name is right !
    ");
    }

    ....how can I do it ?

    Thanks,
    Ben

  • Andy Hassall

    #2
    Re: preg_match search using a variable ?

    On 14 Feb 2005 12:35:56 -0800, "ben" <lessani@gmail. com> wrote:
    [color=blue]
    >I've been tryin to use preg_match to search through a string. But it
    >doesn't seem to function with a variable as the search string. I've
    >tried many variations, but I'm not sure how to do it.
    >
    >$data =
    >file_get_conte nts("http://cgi.ebay.co.uk/ws/eBayISAPI.dll?V iewItem&item=$i number");
    >if(preg_match( '/\$'.$susername. '\./', $data)){
    >print("
    >Sellers name is right !
    >");
    >}
    >
    >...how can I do it ?[/color]

    What's in $susername?

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • ben

      #3
      Re: preg_match search using a variable ?

      lessani_distrib utions

      Comment

      • ben

        #4
        Re: preg_match search using a variable ?

        Okay, I figured it out, god I'm dumb. For other people who ever need to
        do this...

        $data =
        file_get_conten ts("http://cgi.ebay.co.uk/ws/eBayISAPI.dll?V iewItem&item=$i number");
        if(preg_match("/$susername/", $data)){
        print("
        Sellers name is right !
        ");
        }

        That worked !

        Comment

        Working...