brutal318
-
Posts
10 -
Joined
-
Last visited
Never
Posts posted by brutal318
-
-
i can't edit the structure.
<?php
$file = fopen("/home/rock/test.txt", "r");
while (!feof($file) ) {
$line = fgets($file);
$array = explode(' ', $line);
$count=count($array);
for ($i = 0; $i < $count-1; $i++) {
$sum=0;
if($array[$i]=="Author"){$name=$array[$i+1];}
if($array[$i]=="content"){$sum++;}
if($sum>0){echo $name; echo " ";}
}
}
?>
i had fixed this, this can be run, print, but had a problem that if the content have two "content" then it will print two author, who can help me to print only one for author?
-
anyone else help me?
-
Hi
the file content:
Chapter jasgdjgajgsd jagsdjgasd Author class1 kjhasdy akshdhasd
lkhklhad content asdkjkflkasd
Chapter asjkdkjasdjk kjlwuroiqw Author class2 yfk23ds sadhoigfa
kjhasjdh lkhoiyr oiunv9035445
Chapter mmhjk0970973 klishhpswa Author class3 kkjhgfe content content lkhlahd
kjahsdlklaf
I want to print out "class1" and "class3", cause it have "content" in it's content.
-
Hi, anyone can help me?
-
<?php
$file = fopen("/home/rock/test.txt", "r");
while (!feof($file) ) {
$line = fgets($file);
$array = explode(' ', $line);
}
$count = count($array);
$j=0;
$t=0;
for ($i = 0; $i < $count; $i++) {
$boo=true;
while($boo){
$j++;
if($array[$j]="Author"){
$t=$j+1;
$name=$array[$t];}
if($array[$j]="content"){
echo $name;}
if($array[$i]="Chapter"){$boo=false;}
}
}
?>
can you fixed this?
-
it's only seperate and enter beetween line.
-
the data file is only text. So what should i do?
-
I'm sorry, but i had try so many, i can't get it.
I need an example to learn.
$sum=0;
if ($fh = fopen('/var/lib/mysql/mysql-slow....','r')) {
while (! feof($fh)) {
if(stristr($fread($fh),"Chapter")) {
if (stristr($fread($fh),"Author")) {
$name=$fread($fh);
if(stristr($fread($fh),"content")) {
$sum=$sum+1;
}
if ($sum>=1) {echo $name;}
}
}
this is the recently file of mine.
-
Hi, I'm a beginner, i had a problem about get content from file, i had searched but i can't solve my problem:
I have a text file (abc.txt).
It have content like this:
_*Chapter*_ : ... Author: aaa ( and then content .......vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv.......)
_*Chapter*_ : ... Author: bbb ( and then content .........vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv.........)
.....
and it loops like that.
I have a string (abcxyz) that need to find in contents.
If found it in content, print the name of the author (print all author have that content).
the _*Chapter*_ is unique, in content hasn't got that word, but the word Author maybe. But beetween the Chapter and the Author, hasn't another word Author.
Thanks a lot.
PS: I need someone can help me to code this. (don't send me a link to example or something etc...)
PHP file search, get content
in PHP Coding Help
Posted
thanks a lot.
I have my code run.
<?php
$file = fopen("/home/rock/test1.txt", "r");
$post=array("");
while (!feof($file) ) {
$line = fgets($file);
$array = explode(' ', $line);
$count=count($array);
for ($i = 0; $i < $count-1; $i++) {
$sum=0;
if($array[$i]=="use"){$name=substr($array[$i+1],0,-2);}
if($array[$i]=="'help',"){$sum++;}
if($sum>0){
if(!in_array($name,$post)) {
array_push($post,$name);}
}
}
}
for ($i=0; $i<count($post);$i++) {echo $post[$i];echo "\n";}
?>