spires Posted June 10, 2011 Share Posted June 10, 2011 Hi I'm trying to separate each line of a text filed and place each line in to an array one by one. At the moment i'm just trying get echo out the count of how many items a are in the array $expKey; When entering the words in the text field, i'm pressing return to move doen to the next line. I'm adding 4 lines of text. So, the count should be 4. Or am I missing something? $expKey = explode("/n", $_POST['keywords']); echo count($expKey). ' '; Thanks Quote Link to comment Share on other sites More sharing options...
spires Posted June 10, 2011 Author Share Posted June 10, 2011 OK, I have a work around, but i'm sure the other way should work fine. So, if you have another / better way to do it, please let me know. Work Around $expKey = explode("<br />", nl2br($_POST['key_'.$i])); Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 11, 2011 Share Posted June 11, 2011 this: $expKey = explode("/n", $_POST['keywords']); does not work, because the correct newline character is "\n" and not "/n" Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted June 11, 2011 Share Posted June 11, 2011 just use file() This takes a file and returns an array of each different line, which is exactly what you want if im not mistaken EDIT: Sorry misread your post. Yeah you are using the wrong newline character (\n not /n) as webstyles pointed out 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.