email - Find the count of occurrences of a substring within a string in php
I have a string say
$result = \nHey there!Listen\n\n===\n\nLife is one\n\n===\n\nBut cs is 1.6ok\n\n===\n\nI hope you got what i wanna say\n\nSpeech finished\n\n===\n
Now I want to
Find the no of occurences of
\n
in the above string. I have used the below function but it outputs nothing :substr_count($result,"\n");
I want to email
$result
as the Email-body , but\n
characters are appearining as it is. Anyway out there, that I can get rid of these\n
characters and they are actually replaced by a new line in email subject ?
Answer
Solution:
$result = str_replace("\n", chr(13), $result );
I replaced all the \n characters by chr(13) that is interpreted as enter .
So it worked out for me :)