_deep_replace
Perform a deep string replace operation to ensure the values in $search are no longer present.
Description
Repeats the replacement operation until it no longer replaces anything so as to remove nested values e.g. $subject
= %0%0%0DDD,, $search
='%0D', $result
='' rather than the %0%0DD that str_replace would return
Returns (string)
The string with the replaced svalues.
Parameters (2)
- 0. $search (string|array)
- The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
- 1. $subject (string)
- The string being searched and replaced on, otherwise known as the haystack.
Usage
if ( !function_exists( '_deep_replace' ) ) { require_once ABSPATH . WPINC . '/formatting.php'; } // The value being searched for, otherwise known as the needle. // An array may be used to designate multiple needles. $search = null; // The string being searched and replaced on, otherwise known as the haystack. $subject = ''; // NOTICE! Understand what this does before running. $result = _deep_replace($search, $subject);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/formatting.php
- function _deep_replace( $search, $subject ) {
- $subject = (string) $subject;
- $count = 1;
- while ( $count ) {
- $subject = str_replace( $search, '', $subject, $count );
- }
- return $subject;
- }