I'm using strlen() to count the number of chars in a text, but it even counts newline \n. Can i replace newlines is some way to make strlen() don't count them?
use this first replace all new line character by null and than count length.
new line character
null
echo strlen(str_replace(array("\n", "\r\n", "\r"), '', $string));
you can subtract one, like this:
$x = stlen(str); $x--;
<?php $string = "Testing \n testing"; $x = strlen(str_replace(array("\n","\r","\r\n"), "", $string)); //replace '\n \r' with nothing before counting the rest
use this first replace all
new line character
bynull
and than count length.