From 3bcbd35fd98aa15d53b11a4c8873027257d9d05a Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 20 Aug 2013 05:56:22 +0000 Subject: [PATCH] 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 --- src/wp-includes/formatting.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 98bae804b1..6a0869a1d7 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -2570,21 +2570,16 @@ function wp_htmledit_pre($output) { * @since 2.8.1 * @access private * - * @param string|array $search - * @param string $subject - * @return string The processed string + * @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 The string being searched and replaced on, otherwise known as the haystack. + * @return string The string with the replaced svalues. */ function _deep_replace( $search, $subject ) { - $found = true; $subject = (string) $subject; - while ( $found ) { - $found = false; - foreach ( (array) $search as $val ) { - while ( strpos( $subject, $val ) !== false ) { - $found = true; - $subject = str_replace( $val, '', $subject ); - } - } + + $count = 1; + while ( $count ) { + $subject = str_replace( $search, '', $subject, $count ); } return $subject;