PHP - 我怎样才能重写这一部分以使其更专业?

标签 php

如何重写此部分以使其更加专业?也许有某种方法可以将中间 6 行合并为 1 行?

if($hyperlink){
  $hyperlink_new=$hyperlink;
  $hyperlink_new=str_replace("row[0]", $row[0], $hyperlink_new);
  $hyperlink_new=str_replace("row[1]", $row[1], $hyperlink_new);
  $hyperlink_new=str_replace("row[2]", $row[2], $hyperlink_new);
  $hyperlink_new=str_replace("row[3]", $row[3], $hyperlink_new);
  $hyperlink_new=str_replace("row[4]", $row[4], $hyperlink_new);
  $hyperlink_new=str_replace("row[5]", $row[5], $hyperlink_new);
  echo "<a href=\"$hyperlink_new\">";
}

谢谢。

最佳答案

if($hyperlink){
    $hyperlink_new=$hyperlink;
    for ($i=0; $i<6; $i+=1) {
        $hyperlink_new=str_replace("row[$i]", $row[$i], $hyperlink_new);
    }
    echo "<a href=\"$hyperlink_new\">";
}

关于PHP - 我怎样才能重写这一部分以使其更专业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6064532/

相关文章:

java - Java 中的数组数组

php - 优化 Nginx + PHP-FPM 以获得更快的响应时间(用于 Openx 广告服务)

php - highcharts 系列删除功能删除所有原始系列数据(即使存储在新变量中)

php - html/php,上传的文件未存储在 $_FILES 中

javascript - 将日期与 where 子句进行比较

php - 如何修复消息 : SQLSTATE[08004] [1040] Too many connections

php glob 获取正确的路径

php - 查询 mysql php

javascript - 单击提交按钮时如何仅加载内容区域?

php - 如何查看php字节码文件