Php extract link from a html form?

  • Thread starter Thread starter iwasadog
  • Start date Start date
I

iwasadog

Guest
I have placed the contents of a html page into a variable and now i want to extract a link from it. I know how to extract from <a> tags but need to know how to get it from the example below:
<form id="ff" action="http://www.google.com" method="post">

Anyone know how to extract the http://www.google.com part using php?
 
There are a couple routes depending on how much of your information there is constant. If you can get the position in the string where it starts and where it ends, you can use
substr($string, $startpoint, $lengthofaddress);

A couple tips for finding the starting position in the length is to use strpos(); using for instance "http://" as the needle to find where it begins, and an array filled with com, net, org etc.

Please feel free to message me for specifics and maybe I can go into more depth.
 
Back
Top