w3bbi3 Posted July 2, 2010 Share Posted July 2, 2010 Hi, I need a textbox to be placed under each question, too. How do I do that using the code, by lococobra, below? <?php> $content = 'How do I implement textboxes under each question? Do you know how to insert a textbox under this question, too? How about this one? Any clue on how to get a textbox to show up with a textbox underneath this one as well? '; preg_match_all('/(?<=[.?!]|^).*?(?=([.?!]).{0,3}[A-Z]|$)/s',$content,$matches); echo "<pre>"; for($i=0;$i<count($matches[0]);$i++) $result[] = trim($matches[0][$i]).$matches[1][$i]; print_r($result); ?> Thanks. Link to comment https://forums.phpfreaks.com/topic/206467-how-do-i-implement-textboxes/ Share on other sites More sharing options...
litebearer Posted July 2, 2010 Share Posted July 2, 2010 Perhaps this... <?PHP $content = "How do I implement textboxes under each question? Do you know how to insert a textbox under this question, too? How about this one? Any clue on how to get a textbox to show up with a textbox underneath this one as well?"; $question_array = explode($content"?",); $num_q = count($question_array); $i=0; while($i<$num_q) { echo $question_array[$i] . "<br>"; ?> <textarea name="variablename<?PHP echo $i; ?>" rows="3" cols="40"></textarea> <?PHP $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/206467-how-do-i-implement-textboxes/#findComment-1080038 Share on other sites More sharing options...
Cagecrawler Posted July 2, 2010 Share Posted July 2, 2010 If you want to use your original code: <?php $content = 'How do I implement textboxes under each question? Do you know how to insert a textbox under this question, too? How about this one? Any clue on how to get a textbox to show up with a textbox underneath this one as well? '; preg_match_all('/(?<=[.?!]|^).*?(?=([.?!]).{0,3}[A-Z]|$)/s',$content,$matches); for($i=0;$i<count($matches[0]);$i++) $result[] = trim($matches[0][$i]).$matches[1][$i]; ?> <form action="" method=""> <?php for($i=0;$i<count($result);$i++) { echo "<p>".($i+1).") {$result[$i]}<br/>"; //echo '<input type="text" name="answer'.($i+1).'"/></p>'; echo "<textarea></textarea></p>"; } ?> Adjust html to fit your needs. Link to comment https://forums.phpfreaks.com/topic/206467-how-do-i-implement-textboxes/#findComment-1080042 Share on other sites More sharing options...
w3bbi3 Posted July 2, 2010 Author Share Posted July 2, 2010 lightbearer, I couldn't get it to work, but I appreciate your effort though. Cagecrawler, you got it! Thanks! Link to comment https://forums.phpfreaks.com/topic/206467-how-do-i-implement-textboxes/#findComment-1080048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.