Simplify _deep_replace() by removing it's obscure looping and replacement checking logic, and instead, using the PHP5 $count parameter of str_replace(). Props hakre. Fixes #16903

git-svn-id: https://develop.svn.wordpress.org/trunk@25054 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2013-08-20 05:56:22 +00:00
parent 0fbadc1e03
commit 3bcbd35fd9

View File

@ -2570,21 +2570,16 @@ function wp_htmledit_pre($output) {
* @since 2.8.1 * @since 2.8.1
* @access private * @access private
* *
* @param string|array $search * @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
* @param string $subject * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
* @return string The processed string * @return string The string with the replaced svalues.
*/ */
function _deep_replace( $search, $subject ) { function _deep_replace( $search, $subject ) {
$found = true;
$subject = (string) $subject; $subject = (string) $subject;
while ( $found ) {
$found = false; $count = 1;
foreach ( (array) $search as $val ) { while ( $count ) {
while ( strpos( $subject, $val ) !== false ) { $subject = str_replace( $search, '', $subject, $count );
$found = true;
$subject = str_replace( $val, '', $subject );
}
}
} }
return $subject; return $subject;