dongpu1908
dongpu1908
2013-05-16 22:52

从文本文件中挑选国家/地区代码和相应的域

  • readfile
  • fopen
  • regex
  • php

I have a text file like:

en-US -> www.google.co.uk
en-UK -> www.bbc.co.uk
es-CO -> www.somedomain.com

I want to be able to pick out the country/language type for example en-US and the corresponding domain name on the same line. How do I do this?

A start:

 $file = "data.txt";
 $f = fopen($file, "r");

 while ( $line = fgets($f, 1000) ) {

   if (preg_match('/^-> .*$/', $line)) {
      fwrite($out, $fh);
   }
   print $line;
 }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐