monicka87 Posted October 22, 2009 Share Posted October 22, 2009 Hi I need some help to get this done using php: 1 - I have few hyperlinks say 500 in format like: <a href="http://domaina.com/1.html" target="_blank">http://domaina.com/1.html</a> <a href="http://domainb.com/1.html" target="_blank">http://domainb.com/1.html</a> <a href="http://domainc.com/21.html" target="_blank">http://domainc.com/21.html</a> <a href="http://domaind.com/new.php" target="_blank">http://domaind.com/new.php</a> etc etc Now I want to convert them into format like: <a href="http://domaina.com/1.html" target="_blank">keyword 1</a> <a href="http://domainb.com/1.html" target="_blank">keyword 2</a> <a href="http://domainc.com/21.html" target="_blank">keyword 3</a> <a href="http://domaind.com/new.php" target="_blank">keyword 4</a> Here keyword 1,2,3,4 can be taken randomly from a file which has huge list of keywords or may be we can paste the hyperlinks and keywords in php form itself and then it just links into the manner as given above. Can anyone provide the code for doing this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/178636-php-hyperlinks-generator/ Share on other sites More sharing options...
bestrong Posted October 22, 2009 Share Posted October 22, 2009 Hello! I can help you with this code, but first I need to know a few things: 1) You say "I have few hyperlinks say 500 in format like:" -Where are these? Are they being generated? In a table ... a file? 2) You have a file of keywords ... how are they delimited. Comma, newline, space Ben Quote Link to comment https://forums.phpfreaks.com/topic/178636-php-hyperlinks-generator/#findComment-942326 Share on other sites More sharing options...
monicka87 Posted October 23, 2009 Author Share Posted October 23, 2009 Thanks.. I am revising my problem and making it more clear and simple now as: I would need a PHP form page with two form fields: Form Field A- In this box we can paste bulk URLS like http://domaina.com/1.html http://domainb.com/2.html http://domaind.com/my.html http://domaina.com/new.html etc Form Field B- In this box we can paste list of keywords like keyword 1 keyword 2 keyword 3 keyword 4 keyword 5 etc Lastly there is "SUBMIT" button and when we click on it then it provides us code on the page itself in the following manner: <a href="http://domaina.com/1.html">keyword 1</a> <a href="http://domainb.com/2.html">keyword 2</a> <a href="http://domaind.com/my.html">keyword 3</a> <a href="http://domaina.com/new.html">keyword 4</a> etc There is no database or external files requird.. I hope its easy to understand now.. If anyone can create this script then I would be very greatful.. Thanks Monicka Quote Link to comment https://forums.phpfreaks.com/topic/178636-php-hyperlinks-generator/#findComment-942648 Share on other sites More sharing options...
Prismatic Posted October 23, 2009 Share Posted October 23, 2009 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr> <td valign="top"><strong>URLs</strong><br/><textarea cols="50" rows="4" name="urls" id="urls"></textarea></td> <td valign="top"><strong>Keywords</strong><br/><textarea cols="50" rows="4" name="keywords" id="keywords"></textarea></td> </tr> <tr> <td colspan="2"><input type="submit" text="Submit"></td> </tr> </table> </form> <?php $out = ""; if($_POST['urls'] != "" && $_POST['keywords'] != "") { $keywords = explode("\n", $_POST['keywords']); $urls = explode("\n", $_POST['urls']); $out = ""; for($i = 0; $i < count($urls); $i++) { $out .= "<a href='". $urls[$i] ."'>". ($keywords[$i] == "" ? $urls[$i] : $keywords[$i]) ."</a><br/>\n"; } } echo $out; ?> Quote Link to comment https://forums.phpfreaks.com/topic/178636-php-hyperlinks-generator/#findComment-942664 Share on other sites More sharing options...
monicka87 Posted October 23, 2009 Author Share Posted October 23, 2009 Hey... U r absolutely great... cool PHP guy !! Thankssssss a lot !!!! Monicka Quote Link to comment https://forums.phpfreaks.com/topic/178636-php-hyperlinks-generator/#findComment-942879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.