Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with extracting please folks.!

kirill_uk@hotmail.com
Guest
 
Posts: n/a
#1: Sep 26 '05
Help with extracting please folks.!
Hi. I have this:
a variable like: <a href="http://www.some_html.com/text.html" >some
text</a><br>

I heed to extract the "http://www.some_html.com/text.html " and put
it in var "link"
And extract "some text" and put it var "text",.

So basically extract all between <a href=" and " >
plus extract all between " > and </a><br>.
Any idea? Thank you all for your help. Gada finish this project
tonight, or I am totally screwed with my exams..:)


Oli Filth
Guest
 
Posts: n/a
#2: Sep 26 '05

re: Help with extracting please folks.!


kirill_uk@hotmail.com said the following on 26/09/2005 23:34:[color=blue]
> Help with extracting please folks.!
> Hi. I have this:
> a variable like: <a href="http://www.some_html.com/text.html" >some
> text</a><br>
>
> I heed to extract the "http://www.some_html.com/text.html " and put
> it in var "link"
> And extract "some text" and put it var "text",.
>
> So basically extract all between <a href=" and " >
> plus extract all between " > and </a><br>.
> Any idea? Thank you all for your help. Gada finish this project
> tonight, or I am totally screwed with my exams..:)
>[/color]

Please Google it.

http://www.google.co.uk/search?q=extract+urls+html+php


--
Oli
kirill_uk@hotmail.com
Guest
 
Posts: n/a
#3: Sep 27 '05

re: Help with extracting please folks.!


Didn't fined anything useful.:((

Mazin07
Guest
 
Posts: n/a
#4: Sep 27 '05

re: Help with extracting please folks.!


kirill_uk@hotmail.com wrote:[color=blue]
> Didn't fined anything useful.:((
>[/color]

Look up preg_match and preg_match_all
John Dunlop
Guest
 
Posts: n/a
#5: Sep 30 '05

re: Help with extracting please folks.!


kirill_uk wrote:
[color=blue]
> So basically extract all between <a href=" and " >
> plus extract all between " > and </a><br>.[/color]

preg_match(
'`<a href="([^"]+)" >(.*?)</a><br>`',
$subject,
$output)

Disclaimer: in case of contact with arbitrary HTML, rinse immediately.

--
Jock
Closed Thread