discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 still getting a line 23 error Link to comment https://forums.phpfreaks.com/topic/130635-a-few-questions-regarding-an-array/page/2/#findComment-677984 Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 move the echo implode() inside the if(isset()) block. you can't call a variable that wasn't yet defined, and $store only gets defined once a user submits the form (which is when the contents of the if(isset()) block execute). Link to comment https://forums.phpfreaks.com/topic/130635-a-few-questions-regarding-an-array/page/2/#findComment-677988 Share on other sites More sharing options...
discussnow Posted October 30, 2008 Author Share Posted October 30, 2008 Its working now, however, it seems to keep repeating itself almost like the loop isn't stopping. Also the first array entry is repeated twice Link to comment https://forums.phpfreaks.com/topic/130635-a-few-questions-regarding-an-array/page/2/#findComment-677997 Share on other sites More sharing options...
bobbinsbro Posted October 30, 2008 Share Posted October 30, 2008 i'm not sure what your code looks like, but this is built off of yours and it works: <html> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <title> Paragraph Scrambler </title> <body> Paste Paragraph <br> <textarea name="para" type="text" row="5" col="5"></textarea><br> <input name="send" type="submit" value="Submit!"> <input type="reset" value="Cancel"><br /> <?php if(isset($_POST['para'])){ $para = $_POST['para']; $result = split('\.|\?',$para); $loopCount = count($result); for($i = 0; $i < $loopCount; $i++){ if (($i % 2) == 0){ $store[] = $result[$i]; } } echo implode(".",$store); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/130635-a-few-questions-regarding-an-array/page/2/#findComment-678002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.