Questions | Login

Top / PHP

Php extract link from a html form?

demo 18 Dec 2008 07:40am
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?

Answers

demo 18 Dec 2008 08:06am
What do you mean "to extract"? Give an example. :)
demo 18 Dec 2008 08:09am
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.

Related

Submit Answer

You must be logged in to post an answer. Please Login or Register.

Powered by phpMyAnswers.