任务本身是针对Wordpress小部件的。 在每个帖子中,都有类似“ https://www.test.com/example/example1/target”的链接,任务如下:在文本中找到第一个链接“ https://www.test.com/example/example1/”,并创建一个采用“ target”值的变量。这是真的吗?如果是这样,怎么办?我将非常感谢您的帮助。对不起,我的英语!
UPD: 我已经做到了(使用$ company_ticker作为“目标”)
$patt = '~(https://www.test.com/example/example/)(\S+)~';
$company_ticker = '';
if (preg_match($patt, $post_content, $company_ticker)) {
list( , $url, $company_ticker) = $company_ticker;
}
但是我不知道错误在哪里...