PHP

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Getting an argument out of a web page

    3 answers - 273 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I'm trying to read a MySpace FriendID out of a web page. If you view
    the source, you see this is multiple places:
    &friendID=12345&
    What's the simplest way to extract the FriendID and stick it in a
    variable? Is there a regex that would do this?
  • No.1 | | 431 bytes | |

    Brian Dunning wrote:
    I'm trying to read a MySpace FriendID out of a web page. If you view the
    source, you see this is multiple places:

    &friendID=12345&

    What's the simplest way to extract the FriendID and stick it in a
    variable? Is there a regex that would do this?

    Is it always in that format?

    preg_match ( "/&friendID=(\d{5,})&/", $source, $id );

    The result will be in $id[1].
  • No.2 | | 23 bytes | |

    That did it, thanks! :)
  • No.3 | | 267 bytes | |

    Brian Dunning wrote:
    That did it, thanks! :)
    Keep in mind that if the ID is less than 5 digits, it won't match (I
    don't know where MySpace ID's start). You can change it to something
    like \d{1,} if you want it to match 1 or more digits.

Re: Getting an argument out of a web page


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "PHP"

EMSDN.COM