小编Arw*_*wed的帖子

使用Array作为函数的参数

函数内部的代码正在运行,但由于我想要处理多个Url,我想让它成为一个函数,使用数组来获取要处理的URL.这是代码:

    <?php
$site = array("http://www.ihr-apotheker.de/cs1.html", "http://www.ihr-apotheker.de/cs2.html", "http://www.ihr-apotheker.de/cs3.html");

function parseNAI($sites)
  {
  foreach ($sites as $html)
    {
      $clean_one = strstr($html, '<p>');
      $clean_one_class = str_replace('<p><span class="headline">', '<p class="headline gruen"><span>', $clean_one);
      $clean_one_class_a = strip_tags($clean_one_class, '<p><span><a>');
      $clean_one_class_b = preg_replace("/\s+/", " ", $clean_one_class_a);
      $str_one = preg_replace('#(<a.*>).*?(</a>)#', '$1$2', $clean_one_class_b);
      $ausgabe_one = strip_tags($str_one, '<p>');
      echo $ausgabe_one;
    } 
  };
parseNAI($site);
?>
Run Code Online (Sandbox Code Playgroud)

我的问题在哪里,因为该函数在foreach开始时停止工作....请提前帮助你!

php arrays function

1
推荐指数
1
解决办法
200
查看次数

标签 统计

arrays ×1

function ×1

php ×1