Well, I'm baack!! I said it was working, and is is: partly. Problem is, str_ireplace() is stopping midway through the text I'm feeding it. No errors, no notices or warnings; just an incomplete application of the function.
The easiest way I could think of for testing was to remove vowels from text in the Message Textarea. It succeeds with a nice, short message (named "comments" in my code). To start off with I used a lorem ipson paste for the text. About a third+ part of the way through, the replacements stopped. Figureing there might be some foreign text or something in it I switched to my own text, entered right here on my keyboard, for the Message; same thing; OK for short messages, stopped replacing about half way through. So, I've missed something!
For example, if I use the following in the textarea, it works:
"
This is some code to see how ireplace works in removing vowels from $comments.
Therefore, once str_ireplace() is applied, there should be no vowels in it.
"
But, if I extend the text as so, about the same number of characters as Lorum Ipsum I first used:
"
This is some code to see how ireplace works in removing vowels from $comments.
Therefore, once str_ireplace() is applied, there should be no vowels in it.
This is some code to see how ireplace works in removing vowels from $comments.
Therefore, once str_ireplace() is applied, there should be no vowels in it.
This is some code to see how ireplace works in removing vowels from $comments.
Therefore, once str_ireplace() is applied, there should be no vowels in it.
This is some code to see how ireplace works in removing vowels from $comments.
Therefore, once str_ireplace() is applied, there should be no vowels in it.
This is some code to see how ireplace works in removing vowels from $comments.
Therefore, once str_ireplace() is applied, there should be no vowels in it.
"
Then it fails to do all of the replacements partway through. Here are the replaced results:
"
COMMENTS
Ths s sm cd t s hw rplc wrks n rmvng vwls frm $cmmnts. Thrfr, nc str_rplc() s ppld, thr shld b n vwls n t. Ths s sm cd t s hw rplc wrks n rmvng vwls frm $cmmnts. Thrfr, nc str_rplc() s ppld, thr shld b n vwls n t. Ths s sm cd t s hw rplc wrks n rmvng vwls frm $cmmnts. Thrfr, nc str_rplc() s ppld, thr shld b n vwls n t. Ths s sm cd t s hw rplc wrks n rmvng vwls frm $cmmnts. Thrfr, nc str_rplc() s ppld, thr shld b n vwls n t. Ths s sm cd t s hw rplc wrks n rmvng vwls frm $cmmnts. Thrfr, nc str_rplc() s ppld, thr shld b n vwls n t. This is some code to see how ireplace works in removing vowels from $comments. Therefore, once str_ireplace() is applied, there should be no vowels in it. This is some code to see how ireplace works in removing vowels from $comments. Therefore, once str_ireplace() is applied, there should be no vowels in it. This is some code to see how ireplace works in removing vowels from $comments. Therefore, once str_ireplace() is applied, there should be no vowels in it. This is some code to see how ireplace works in removing vowels from $comments. Therefore, once str_ireplace() is applied, there should be no vowels in it. This is some code to see how ireplace works in removing vowels from $comments. Therefore, once str_ireplace() is applied, there should be no vowels in it.
"
I italicised the text where it stopped working, for clarity.
Here's the code I'm using:
$comments=$_POST['comments'];
echo "COMMENTS"."<br />";
str_replace("/",$_POST['comments'],"");
$comments= stripslashes($_POST['comments']);
trim($comments);
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "$comments");
echo $onlyconsonants;
$comments = strip_tags($comments);
$comments = htmlspecialchars($comments);
echo $comments."<br />";
I've read & re-read the manual & other places and they all seem to indicate this should work, including the "gotchas" to no avail.
What am I missing?
Regards,
Rivet`