php foreach counting new lines (\n)
问题 If I have a piece of code that works like this: $i = 0; $names = explode(",", $userInput); foreach($names as $name) { $i++; } It works perfectly, provided the user has placed a comma after each name entered into the html textarea this comes from. But I want to make it more user friendly and change it so that each name can be entered on a new line and it'll count how many lines the user has entered to determine the number of names entered into the field. So I tried: $i = 0; $names = explode("