danoli3 Posted April 28, 2009 Share Posted April 28, 2009 Hey I have been trying really hard to find some documentation on how to pass the values from a Textarea form back to the page to display the values as hyperlinks (if they are hyperlinks, but for this they are all hyperlinks) For example: Textarea: http://www.google.com/download1.rar http://www.google.com/download2.rar http://www.google.com/download3.rar http://www.google.com/download4.rar Preview Button <- Click and then page displays the links in the textarea in another place as links. So you can use a program like download them all to 'download all rar links'. Any idea? How to separate line to line in the final equation and then I can attach the a hrefs... help Link to comment https://forums.phpfreaks.com/topic/155953-textarea-to-hyperlinkss/ Share on other sites More sharing options...
Prismatic Posted April 28, 2009 Share Posted April 28, 2009 <?php // Our simulated text area. Note the newlines. $data = "http://www.google.com\n http://www.yahoo.com\n http://www.ask.com\n http://www.aol.com"; // Seperate each line at it's newline character $lines = explode("\n", $data); // Show each one as a link foreach($lines as $line) { echo "<a href=\"{$line}\">{$line}</a></br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/155953-textarea-to-hyperlinkss/#findComment-820941 Share on other sites More sharing options...
danoli3 Posted April 28, 2009 Author Share Posted April 28, 2009 AWesome! that works! I set it up like this: <?php echo '<center>'; echo '<br><br><form action="'.$_SERVER['PHP_SELF'].'" method="post">'; echo '<textarea name="links" cols="60" rows="10">'; if(isset($_POST['links'])) { echo stripslashes($_POST['links']); } echo '</textarea><br>'; echo '<input type="submit" name="submit" value="Preview For Download Them All!"></center>'; if(isset($_POST['submit'])) { echo '<center>'; // Our simulated text area. Note the newlines. $data = stripslashes($_POST['links']); // Seperate each line at it's newline character $lines = explode("\n", $data); echo '<table bgcolor="#efefef" width="500">'; // Show each one as a link foreach($lines as $line) { echo "<tr><td>"; echo "<a href=\"{$line}\">{$line}</a></br>"; echo "</td></tr>"; } echo '</table>'; } ?> Any improvements you think I could add? Link to comment https://forums.phpfreaks.com/topic/155953-textarea-to-hyperlinkss/#findComment-820946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.