简体   繁体   English

如何在php数组中插入mailto链接?

[英]How to Insert mailto link inside php array?

I want to insert a mailto link to my php footer.我想插入一个mailto 链接到我的php 页脚。 How should i go about to create that?我应该如何去创造它? This is my code so far.到目前为止,这是我的代码。

 <?php $names = array("&copyDusan Biga", "&copyStian Stord", "&copyAsle Foss");
   $arrlength = count($names);

   for($x = 0; $x < $arrlength; $x++) {
   echo $names[$x];
   echo "<br>";
}
?>

It is basic footer content.它是基本的页脚内容。 So i want it to have a mailto link right next to the names.所以我希望它在名称旁边有一个mailto链接。 So "&copyDusan Biga (mailto link here)" .所以“&copyDusan Biga (mailto link here)” Thanks in advance!提前致谢!

It's not a very professional approach but, as you say, if it's for practice, it's all right, we all have to learn.这不是一个非常专业的方法,但是,正如你所说,如果是为了练习,那没关系,我们都必须学习。

One of the 10000000000000 options is: 100000000000000 个选项之一是:

<?php 
$names = array("&copyDusan Biga", "&copyStian Stord", "&copyAsle Foss");
$emails = array("biga@mail.yes", "stian@mail.yes", "foss@mail.yes");
$arrlength = count($names);

for($x = 0; $x < $arrlength; $x++) {
   echo $names[$x]. " - <a href='mailto:".$emails[$x]."'>".$emails[$x]."</a>";
   echo "<br>";
}
?>

A better one would be:更好的方法是:

<?php
$names = array(
"&copyDusan Biga"=>"biga@mail.yes", 
"&copyStian Stord"=>"stian@mail.yes", 
"&copyAsle Foss"=>"foss@mail.yes");

foreach($names as $name=>$email) {
     echo $name. " - <a href='mailto:".$email."'>".$email."</a>";
     echo "<br/>";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM