wp_extract_urls( string $content )
Use RegEx to extract URLs from arbitrary content.
Description Description
Parameters Parameters
- $content
-
(string) (Required) Content to extract URLs from.
Return Return
(array) URLs found in passed string.
Source Source
File: wp-includes/functions.php
function wp_extract_urls( $content ) { preg_match_all( "#([\"']?)(" . '(?:([\w-]+:)?//?)' . '[^\s()<>]+' . '[.]' . '(?:' . '\([\w\d]+\)|' . '(?:' . "[^`!()\[\]{};:'\".,<>«»“”‘’\s]|" . '(?:[:]\d+)?/?' . ')+' . ')' . ")\\1#", $content, $post_links ); $post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) ); return array_values( $post_links ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.7.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example
This Code:
Will return an array like this: