PHP - 自动 Rel="nofollow" 外部 link

PHP - auto Rel="nofollow" external link

我有生成 links 的代码:

<div class="header-social">
    <?php foreach( $mts_options['mts_header_social'] as $header_icons ) : ?>
        <?php if( ! empty( $header_icons['mts_header_icon'] ) && isset( $header_icons['mts_header_icon'] ) ) : ?>
             <a href="<?php print $header_icons['mts_header_icon_link'] ?>" class="header-<?php print $header_icons['mts_header_icon'] ?>" style="background: <?php print $header_icons['mts_header_icon_bg_color'] ?>" target="_blank"><span class="fa fa-<?php print $header_icons['mts_header_icon'] ?>"></span></a>
        <?php endif; ?>
    <?php endforeach; ?>
</div>

我只想在 link 是外部域的情况下插入 rel="nofollow"。

我该如何进行?你能帮帮我吗?

非常感谢

我可以在生成代码时提出这样的建议,这似乎是一种解决方法:

    if(substr($header_icons['mts_header_icon_link'], 0, 4) == "http"){echo "rel='nofollow'"; }

如果有帮助请告诉我。