使用php在锚定标记之间提取url
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用php在锚定标记之间提取url相关的知识,希望对你有一定的参考价值。
good for parsing a message for urls so you can process them for character length when displayed on screen
/** Returns an array containing each of the sub-strings from text that are between openingMarker and closingMarker. The text from openingMarker and closingMarker are not included in the result. This function does not support nesting of markers. */ function returnSubstrings($text, $openingMarker, $closingMarker) { $position = 0; $position += $openingMarkerLength; $position = $closingMarkerPosition + $closingMarkerLength; } } return $result; } $msg = "This is a string with a url in <a href="http://www.google.co.uk/search?q=php&num=100&hl=en&safe=off&start=200&sa=N">http://www.google.co.uk/search?q=php&num=100&hl=en&safe=off&start=200&sa=N</a>" $urls = returnSubstrings($msg,'">','</a>'); // array ( // 0 => 'http://www.google.co.uk/search?q=php&num=100&hl=en&safe=off&start=200&sa=N' // ) //
以上是关于使用php在锚定标记之间提取url的主要内容,如果未能解决你的问题,请参考以下文章
使用 JavaScript/jQuery 将 URL 保存在锚标记中?