wp_extract_urls
函数
wp_extract_urls ( $content )
- 参数
-
-
(string)
$content
Content to extract URLs from.- Required: 是
-
(string)
- 返回值
-
- (string[]) Array of URLs found in passed string.
- 定义位置
-
-
wp-includes/functions.php
, line 830
-
wp-includes/functions.php
- 引入
- 3.7.0
- 弃用
- –
使用RegEx从任意的内容中提取URLs。
function wp_extract_urls( $content ) { preg_match_all( "#(["']?)(" . '(?:([w-]+:)?//?)' . '[^s()]+' . '[.]' . '(?:' . '([wd]+)|' . '(?:' . "[^`!()[]{}:'".,«»“”‘’s]|" . '(?:[:]d+)?/?' . ')+' . ')' . ")1#", $content, $post_links ); $post_links = array_unique( array_map( static function( $link ) { // Decode to replace valid entities, like &. $link = html_entity_decode( $link ); // Maintain backward compatibility by removing extraneous semi-colons (`;`). return str_replace( ';', '', $link ); }, $post_links[2] ) ); return array_values( $post_links ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。