Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-26-2006, 03:48 PM   #1
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
PHP code help needed.

Hi i'm stuck on where to add my Do While Loop statement ... below is the section of the coding that is being processed. what is happening is the source is examined and the version codes are grabbed. but, it needs to loop through the source and grab all version codes and not just the first one.

thanks in advance

Code:
                $resp = curl_exec($ch); 
                //echo "$resp\n"; 
                curl_close($ch);       
                $startkey = "<024version>"; 
                $stopkey = "</024version>";         
                $startpos = strpos($resp, $startkey);  
                if ($startpos !hahahaha false) {  
                    $startpos += strlen($startkey);  
                    $endpos = strpos($resp, $stopkey, $startpos); 
                    $len = ($endpos - $startpos);  
                    $writecontent .= substr($resp, $startpos, $len)."\n";  
                    echo "$writecontent\n"; 
     
                } 
$fp = fopen($outputfile,"w"); 
fwrite($fp,$writecontent); 
fclose($fp);
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 04:12 PM   #2
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
use regexp not some gay strpos setup you have...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 04:55 PM   #3
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by woj
use regexp not some gay strpos setup you have...
the gay was was the only way i knew... with regexp is it possible to grab the data from in between <024version>Model#</024version>? The examples of regexp usage i'm finding pretty much shows how to replace.

also back to my original question where should my do loop go?
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 04:59 PM   #4
mfps
Confirmed User
 
Join Date: Mar 2006
Location: southern california
Posts: 640
http://us3.php.net/xml
__________________
mfps is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:00 PM   #5
mrkris
Confirmed User
 
Join Date: May 2005
Posts: 2,737
Quote:
Originally Posted by mfps
If all the data isn't XML he's gonna have a hell of a time
__________________

PHP-MySQL-Rails | ICQ: 342500546
mrkris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:02 PM   #6
mrkris
Confirmed User
 
Join Date: May 2005
Posts: 2,737
Quote:
Originally Posted by acctman
Hi i'm stuck on where to add my Do While Loop statement ... below is the section of the coding that is being processed. what is happening is the source is examined and the version codes are grabbed. but, it needs to loop through the source and grab all version codes and not just the first one.

thanks in advance

Code:
                $resp = curl_exec($ch); 
                //echo "$resp\n"; 
                curl_close($ch);       
                $startkey = "<024version>"; 
                $stopkey = "</024version>";         
                $startpos = strpos($resp, $startkey);  
                if ($startpos !hahahaha false) {  
                    $startpos += strlen($startkey);  
                    $endpos = strpos($resp, $stopkey, $startpos); 
                    $len = ($endpos - $startpos);  
                    $writecontent .= substr($resp, $startpos, $len)."\n";  
                    echo "$writecontent\n"; 
     
                } 
$fp = fopen($outputfile,"w"); 
fwrite($fp,$writecontent); 
fclose($fp);
If it's not all XML, use preg_match_all()
http://us3.php.net/preg_match_all
__________________

PHP-MySQL-Rails | ICQ: 342500546
mrkris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:02 PM   #7
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
its not all xml =/
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:03 PM   #8
mfps
Confirmed User
 
Join Date: Mar 2006
Location: southern california
Posts: 640
ahhh theres a function for just about everything
__________________
mfps is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:04 PM   #9
fallenmuffin
Confirmed User
 
fallenmuffin's Avatar
 
Industry Role:
Join Date: Nov 2005
Posts: 8,170
Woah, your code just took me back to 1995.. thank ya
fallenmuffin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:18 PM   #10
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by mrkris
If it's not all XML, use preg_match_all()
http://us3.php.net/preg_match_all
something like this would grab all without running a do loop?...
Code:
preg_match_all('|<024version>(.*?)</024version>|',$resp,$writecontent);
hehe fallenmuffin yeah i know my coding sucks... i need update my php reference book

Last edited by acctman; 06-26-2006 at 05:20 PM..
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 05:24 PM   #11
mrkris
Confirmed User
 
Join Date: May 2005
Posts: 2,737
Quote:
Originally Posted by acctman
something like this would grab all without running a do loop?...
Code:
preg_match_all('|<024version>(.*?)</024version>|',$resp,$writecontent);
hehe fallenmuffin yeah i know my coding sucks... i need update my php reference book
Yup, one function to search an entire string for multiple matches.
__________________

PHP-MySQL-Rails | ICQ: 342500546
mrkris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 11:03 PM   #12
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
ok seems to be working except one issue... damn array.. how do you pull the results from the array... it's listing them one i do a print_r but but will not output them to the. all i'm getting in the file is Array repeated on each line

Code:
$lookfor ="|<024version>(.*?)</024version>|Ui";	
preg_match_all($lookfor,$html,$results);

print_r($results[1]); 
$writecontent .= "$results[1]\n";

echo "$result[1]\n";

$fp = fopen($outputfile,"a");
fwrite($fp,$writecontent);
fclose($fp);
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 11:21 PM   #13
J.P.
Confirmed User
 
Join Date: Jun 2004
Posts: 689
Code:
$lookfor = '|<024version>(.*)</024version>|Ui';
preg_match_all($lookfor,$html,$results,PREG_PATTERN_ORDER);

$writecontent = '';
for ($c = 0; $c < sizeof($results[1]); $c++) {
    $writecontent .= $results[1][$c]."\n";
}

$fp = fopen($outputfile,'a');
fwrite($fp,$writecontent);
fclose($fp);
this should do it...
__________________
Webmasters! Looking for new affiliate programs to promote?
Affiliate Program Search <-- Search for programs with FHGs, RSS feed, specific niche sponsors, ...
J.P. is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-26-2006, 11:38 PM   #14
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
thank you =)
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.