English 中文(简体)
PHP Parse 档案,取代不需要的物品
原标题:PHP Parse File, replacing not required items going wrong

我试图从以下档案(从网上上载)中将每个IP线连接起来,而Im将储存数据库中的数值,以便将其放在一个阵列中。

其装载来源如下:

12174 in store for taking<hr>221.223.89.99:8909

<br>123.116.123.71:8909

<br>221.10.162.40:8909

<br>222.135.5.38:8909

<br>120.87.121.122:8909

<br>118.77.254.242:8909

<br>218.6.19.14:8909

<br>113.64.124.85:8909

<br>123.118.243.239:8909

<br>124.205.154.181:8909

<br>124.117.13.116:8909

<br>183.7.223.212:8909

<br>112.239.205.245:8909

<br>118.116.235.156:8909

<br>27.16.28.174:8909

<br>222.221.142.59:8909

<br>114.86.40.251:8909

<br>111.225.105.142:8909

<br>115.56.86.62:8909

<br>59.51.108.142:8909

<br>222.219.39.194:8909

<br>114.244.252.246:8909

<br>202.194.148.41:8909

<br>113.94.174.239:8909

<br><hr>total£º 24¡£

因此,我猜测I m 想在<代码><hr>之间做任何事情,并按行文添加每一行。

However doing the following doesn t seem to be working (in terms of stripping it the parts i dont want)

<?php
$fileurl = "**MASKED**";

$lines = file($fileurl);

foreach ($lines as $line_num => $line) {

    $line2 = strstr($line,  taking ,  true );
    $line3 = str_replace($line2,   , $line);
    print_r($line3);

}

?>
最佳回答

如果你想把价值观添加到一个阵列中,那么为什么不直接这样做? 我这样说:

$output = array();
foreach ($lines as $line) {
    if(preg_match("/<br>d/", $line)) {
        $output[] = substr($line, 4);
    }
}
print_r($output);
问题回答

Look into PHP function explode: http://www.php.net/manual/en/function.explode.php

它可以采取扼杀行动,并通过以具体特性分立的方式,形成一种阵容。 如果是的话,这或许是<br>

此外,<代码>trim功能可在需要时摆脱白色空间。





相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签