到目前为止我已经尝试过以下操作:
<?php
// The Regular Expression filter
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$text = "The text I want to filter is here. It has urls http://www.example.com and http://www.example.org";
// Check if there is a url in the text
if(preg_match($reg_exUrl, $text, $url)) {
// make the urls hyper links
$final = preg_replace($reg_exUrl, "<a href=\"{$url[0]}\">{$url[0]}</a> ", $text);
echo $final;
} else {
// if no urls in the text just return the text
echo $text;
}
Run Code Online (Sandbox Code Playgroud)
我面临的唯一问题是,这会将两个 URL 替换为相同的 URL(即第一个找到的 URL)。我如何用loop自己的网址替换每个网址?
我想在php中创建字母系列.我想要创建的系列是这样的:
AAAA
AAAB
AAAC
.
.
.
.
.
.
.
ZZZY
ZZZZ
Run Code Online (Sandbox Code Playgroud)
我不想要任何数字.纯字母系列.我可以用什么方法来创建它?任何提示或伪代码都会有所帮助.
我已经完成range function并使用ascii值来打印字母表,但仍然找不到创建这样一个系列的好方法.