[英]PHP - Random Ahrefs Anchor Text ? Any Advise
Hello I am trying to create a small php script that I have a question about all this script is suppose to do is read a local.txt file stored on my server with a list of plain urls.你好,我正在尝试创建一个小的 php 脚本,我有一个关于所有这个脚本的问题,假设是读取存储在我的服务器上的 local.txt 文件,其中包含一个纯 url 列表。 the script will grab 100 random urls from the.txt file and echo them into clickable anchor text anchor links based on anther text file with my keywords loaded 1 on each line.
该脚本将从 .txt 文件中获取 100 个随机 url,并将它们回显到可点击的锚文本锚链接中,该链接基于花药文本文件,每行加载我的关键字 1。 I cant figure out how to make this happen please review code below as its as far as I got.
我不知道如何做到这一点,请尽我所能查看下面的代码。 Example
例子
list.txt列表.txt
url1网址 1
url2网址2
url3网址3
---- need Output ----需要Output
keyword.txt关键词.txt
anchor text word 1锚文本词 1
anchor text word 2锚文本词 2
anchor text word 3 ect..锚文本词 3 等..
100 or whatever number i set. 100 或我设置的任何数字。
Goal:目标:
echo '<a href="url">anchor text word</a>'; << up to 100 or limit I set
$lines = file("list.txt");
$keywords = file("keywords.txt");
Shuffle($lines);
Shuffle($keywords);
function url_to_clickable_link($lines) {
return preg_replace(
'%(https?|ftp)://([-A-Z0-9-./_*?&;=#]+)%i',
'<a target="blank" rel="nofollow" href="$0" target="_blank">$0</a>', $lines);
}
Echo implode("<br>", array_slice(url_to_clickable_link($lines), 0, 100));
Got stuck did not work.卡住了没有用。
$lines = file("list.txt");
$keywords = file("keywords.txt");
shuffle($lines);
shuffle($keywords);
for ($i = 0; $i < 100; ++$i) {
echo "<a href='$lines[$i]' target='_blank' rel='nofollow'>$keywords[$i]</a><br>\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.