Hello, I have been working for this basic function for 4-5 hours. I have changed it using differnet functions but it is not working. What i try to do is to collect some datas from a form, and output the data that are consisting of only only letters. Problem is the function i have written is working properly if i do the regexp checking in each array myself, but it is not in working properly, only checks the latest item in foreach, the others not. Please let me know where i am doing the mistake or gonna eat the nuts. What i am doing is : 1) split all items that comes from textbox by newline 2) in a loop , i check each data if it has only a-z letters in it. (the regexp i iplemented working properly alread when i check myself any string) <form action='index.php' method='POST'> <textarea name="FILTER" cols=10 rows=10></textarea> <input type='hidden' name='action' value='validate'> <p> <input type='submit' value='Submit'> </form> <?php $str= $_REQUEST['FILTER']; $FILTER = explode("\n", $str); //echo "WRITING THE ALL DATA WITHOUT FILTERING : <br>"; //echo "KeyID | Value<br>"; foreach($FILTER as $key => $value) { // echo $key . ":" . $value . "<br>"; if (eregi('^[a-zA-Z]+$', $value)) { echo 'FILTERED:'. " " .$value . "<br>"; } } ?> PHP:
Before exploding the string, assure that you have converted different new lines types to unix standard. $str = preg_replace('/\r\n|\r/', "\n", $str); $FILTER = explode("\n", $str); Code (php):