spires Posted March 14, 2008 Share Posted March 14, 2008 Hi Guys. I'm trying to join two arrays together. I'm inputing one row of words into one textarea and another row of words into another textarea. Then trying to join the two lots of text tpgether. Example: textarea 1: blackberry black berry textarea 2: pearl curve Results: blackberry pearl blackberry curve black berry pearl black berry curve Here the site so far: http://www.spirestest.com/Adwords%20tools/extend-keywords.php Here is my code so far: <form name="form1" method="post" action="<?php echo $PHP_SELF; ?>"> <table width="1100" border="0" cellspacing="0" cellpadding="0"> <tr> <td><textarea name="keywords" cols="60" rows="8" class="body_text" id="keywords"><?PHP echo stripslashes($_POST['keywords']); ?></textarea></td> <td><textarea name="ext_keywords" cols="60" rows="8" class="body_text" id="ext_keywords"><?PHP echo stripslashes($_POST['ext_keywords']); ?></textarea></td> </tr> <tr> <td><input name="submit12" type="submit" value="submit" /></td> <td> </td> </tr> </table> </form> <BR> <?php $keywords = stripslashes($_POST['keywords']); $keyword_array = explode("\n", $keywords); $ext_keywords = stripslashes($_POST['ext_keywords']); $ext_keyword_array = explode("\n", $ext_keywords); // $keyword = $keyword_array[1]; foreach ($keyword_array as $keyword) { $keyword = trim($keyword); } foreach ($ext_keyword_array as $ext_keywords) { $ext_keywords = trim($ext_keywords); } $key = $keyword.' '.$ext_keywords; ?> <form name="form2" method="post" action="<?php echo $PHP_SELF; ?>"> <table width="1100" border="0" cellspacing="0" cellpadding="0"> <tr> <td><textarea name="key" cols="60" rows="8" class="body_text" id="keywords"><?PHP echo $key; ?></textarea></td> <td></td> </tr> <tr> <td><input name="submit12" type="submit" value="submit" /></td> <td> </td> </tr> </table> </form> Thanks for your help Quote Link to comment Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 [pre] $array1 = array('blackberry', 'black berry'); $array2 = array('pearl', 'curve'); foreach ($array1 as $row1) foreach($array2 as $row2) echo $row1 . " " . $row2 . "<br>"; [/pre] Quote Link to comment Share on other sites More sharing options...
spires Posted March 14, 2008 Author Share Posted March 14, 2008 Hi I just try it, but it didn't help. $keywords = stripslashes($_POST['keywords']); $keyword_array = explode("\n", $keywords); $ext_keywords = stripslashes($_POST['ext_keywords']); $ext_keyword_array = explode("\n", $ext_keywords); foreach ($keyword_array as $keywords) { foreach ($ext_keyword_array as $ext_keywords) { $keywords = trim($keywords); $ext_keywords = trim($ext_keywords); $key = $keywords.' '.$ext_keywords; } } Any other ideas please Thanks for your help Quote Link to comment Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 Looking at your code I see quite a few html errors and logic errors Im not 100% how this should work but try <? $keywords = stripslashes($_POST['keywords']); $keyword_array = explode("\n", $keywords); $ext_keywords = stripslashes($_POST['ext_keywords']); $ext_keyword_array = explode("\n", $ext_keywords); // $keyword = $keyword_array[1]; foreach ($keyword_array as $keyword) { $keyword = trim($keyword); } foreach ($ext_keyword_array as $ext_keywords) { $ext_keywords = trim($ext_keywords); } foreach ($keyword_array as $keywords) { foreach ($ext_keyword_array as $ext_keywords) { $keywords = trim($keywords); $ext_keywords = trim($ext_keywords); $key .= $keywords.' '.$ext_keywords."\n"; } } ?> <form name="form1" method="post" action="<?php echo $PHP_SELF; ?>"> <table width="1100" border="0" cellspacing="0" cellpadding="0"> <tr> <td><textarea name="keywords" cols="60" rows="8" class="body_text" id="keywords"><?PHP echo stripslashes($_POST['keywords']); ?></textarea></td> <td><textarea name="ext_keywords" cols="60" rows="8" class="body_text" id="ext_keywords"><?PHP echo stripslashes($_POST['ext_keywords']); ?></textarea></td> </tr> <tr> <td><input name="submit12" type="submit" value="submit" /></td> <td> </td> </tr> </table> <table width="1100" border="0" cellspacing="0" cellpadding="0"> <tr> <td><textarea name="key" cols="60" rows="8" class="body_text" id="keywords"><?PHP echo $key; ?></textarea></td> <td></td> </tr> <tr> <td><input name="submit12" type="submit" value="submit" /></td> <td> </td> </tr> </table> </form> <BR> Quote Link to comment Share on other sites More sharing options...
spires Posted March 14, 2008 Author Share Posted March 14, 2008 Thanks, That worked perfect :-) Cheers Quote Link to comment 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.