Services_JSON::reduce_string
Deprecated since 5.3.0. It is no longer supported and may be removed in future releases. Use
PHP native JSON extension instead.reduce a string by removing leading and trailing comments and whitespace
Method of the class: Services_JSON{}
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
String. string value stripped of comments and whitespace
Usage
$Services_JSON = new Services_JSON(); $Services_JSON->reduce_string( $str );
- $str(required)
- .
Changelog
| Deprecated since 5.3.0 | Use the PHP native JSON extension instead. |
Services_JSON::reduce_string() Services JSON::reduce string code WP 6.9.1
function reduce_string($str)
{
_deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}