|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-01 06:02 UTC] zane at zanehooper dot com
Description:
------------
I am making a bad word replacer using certain profanity settings. Basically, when
I use str_ireplace inside of ob_start, a lot of the capitals on the page are
removed (I didn't see any capitals added).
I'm not sure why it is happening, but I really need this fixed.
Test script:
---------------
function optimizeHTML( $html )
{
$html = str_ireplace( $badwords_array, $replacement, $html );
return $html;
}
ob_start( 'optimizeHTML' );
Expected result:
----------------
A regular page with $badwords_array replaced by $replacement
Actual result:
--------------
Some capitals on the page are removed
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 12:00:01 2025 UTC |
Okay, the full script with PHP tags: <?php function optimizeHTML( $html ) { $badwords_array = array( ); $replacement = ''; $html = str_ireplace( $badwords_array, $replacement, $html ); return $html; } ob_start( 'optimizeHTML' ); ?> This is CapItalized. The I or C in CapItalized might be removed, as well as the T in This or The.That's still incomplete, since it doesn't include the actual array you're giving str_ireplace() (which is kind of important). Honestly, I'm kind of inclined to suspect it's a problem in your code, rather than PHP, since the following code works for me on PHP 5.2: <?php function filter_output($text) { $adjectives = array('quick', 'brown'); return str_ireplace($adjectives, '', $text); } ob_start('filter_output'); echo 'The Quick Brown Fox Jumps Over The Lazy Dog'; ob_end_flush(); // Should end up printing "The Fox Jumps Over The Lazy Dog" ?>