函数文档

urldecode_deep()

💡 云策文档标注

概述

urldecode_deep() 是一个 WordPress 函数,用于递归遍历数组、对象或标量值,并解码其中的 URL 编码字符串。它基于 map_deep() 实现,简化了对嵌套数据结构进行 URL 解码的操作。

关键要点

  • 函数用途:递归解码 URL 编码值,适用于数组、对象或标量输入。
  • 参数:$value(必需),可以是数组或字符串,表示要解码的数据。
  • 返回值:返回解码后的值,类型与输入一致。
  • 实现方式:内部调用 map_deep() 函数,应用 urldecode 回调。
  • 相关函数:map_deep(),用于将函数映射到数组或对象的非可迭代元素。
  • 版本历史:自 WordPress 4.4.0 版本引入。

代码示例

$decoded_url = urldecode( 'example.com/search/search+query%3Fpost_type%3Dproduct' );

echo $decoded_url;

输出结果:example.com/search/search query?post_type=product


📄 原文内容

Navigates through an array, object, or scalar, and decodes URL-encoded values

Parameters

$valuemixedrequired
The array or string to be decoded.

Return

mixed The decoded value.

Source

function urldecode_deep( $value ) {
	return map_deep( $value, 'urldecode' );
}

Changelog

Version Description
4.4.0 Introduced.

User Contributed Notes