Raised This Month: $32 Target: $400
 8% 

How to get rid of lines before and after str?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kapuzzino
Member
Join Date: Jan 2014
Old 02-05-2014 , 09:40   How to get rid of lines before and after str?
Reply With Quote #1

For example:

PHP Code:
nclose
Content
-Typetext/html

The string what I need
<!-- Hosting24 Analytics Code 
And I want to get only the string what I need

Last edited by Kapuzzino; 02-05-2014 at 09:42.
Kapuzzino is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-05-2014 , 14:29   Re: How to get rid of lines before and after str?
Reply With Quote #2

Well, how do you know which line is the line you need? Does that line always end with a new line character?
__________________
fysiks is offline
Kapuzzino
Member
Join Date: Jan 2014
Old 02-05-2014 , 14:35   Re: How to get rid of lines before and after str?
Reply With Quote #3

@fysiks I did this:

PHP Code:
new arg1[128];
new 
arg2[128];
new 
arg3[128];
new 
arg4[128];
new 
arg5[128];
new 
arg6[128];
new 
arg7[128];
new 
arg8[128];
new 
arg9[128];
       
split(g_Data,arg1,127,arg2,127,"^n");
split(arg2,arg3,127,arg4,127,"^n");
split(arg4,arg5,127,arg6,127,"^n");
split(arg6,arg7,127,arg8,127,"^n");
       
server_print("%s"arg7); 
but I'm not sure it right, tho working.
Kapuzzino is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-05-2014 , 14:39   Re: How to get rid of lines before and after str?
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
Well, how do you know which line is the line you need?
__________________
fysiks is offline
Kapuzzino
Member
Join Date: Jan 2014
Old 02-05-2014 , 14:41   Re: How to get rid of lines before and after str?
Reply With Quote #5

tested.
Kapuzzino is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-05-2014 , 15:00   Re: How to get rid of lines before and after str?
Reply With Quote #6

Quote:
Originally Posted by Kapuzzino View Post
tested.
That doesn't answer the question. If you are sure that your supposed solution will ALWAYS work, then you are implying that your text of interest will ALWAYS be on the same line. This is generally a bad unless you have control over every singe line that is returned by the webpage.

Anyways, a quicker way to do this would be to loop through and count the \n characters. When you get to the one before your text, start recording the characters into a string until you reach the next \n.

The next thing that should be asked is, why do you have a bunch of irrelevant HTML stuff there? Are you refusing to do what I've suggested in your other thread?

EDIT: It's becoming frustrating by you making so many thread all in the same context.
__________________

Last edited by fysiks; 02-05-2014 at 15:04.
fysiks is offline
Kapuzzino
Member
Join Date: Jan 2014
Old 02-05-2014 , 15:05   Re: How to get rid of lines before and after str?
Reply With Quote #7

this HTML staffs cause I'm using free-webhosting, I can't avoid them, but they're definitily in static, so I can do like I did.

@fysiks

I'm not sure what thread you mean.
Kapuzzino is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-05-2014 , 15:20   Re: How to get rid of lines before and after str?
Reply With Quote #8

Quote:
Originally Posted by Kapuzzino View Post
this HTML staffs cause I'm using free-webhosting, I can't avoid them, but they're definitily in static, so I can do like I did.
What? None of that statement makes sense.
__________________
fysiks is offline
Kapuzzino
Member
Join Date: Jan 2014
Old 02-05-2014 , 15:24   Re: How to get rid of lines before and after str?
Reply With Quote #9

php code:

PHP Code:
$fgc file_get_contents("http://www.fcdynamo.kiev.ua");

// echo $fgc;

preg_match_all("/id=\"tab3-1\".*active.*<td>(\d)<\/td>.*(Динамо).*<\/td>/Uis",$fgc,$matches);

/*echo '<pre>';
print_r($matches);
echo '</pre>';*/

echo "Dinamo Kiev is on the ".$matches[1][0]."-nd place in Premier League"
and a module.
Kapuzzino is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode