[PHP] Extracting hyperlinks from file
I need to produce an array of all the links(hrefs) in a remote file (actually those that refer to files in the same remote server, but thats another matter). I'm pretty new to php, i was thinking of doing it with ereg, something like eregi("a href[\"]?=(.*)>", $file, $link); but i cannot think of a way to make it walk through the whole string, so it would find all the links, not just the first one. Any ideas? Ando -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sorry about multiple posts
Just that i sent the message about 15 hours ago, so i thought it didnt get through. Dunno why it took so long. And thanks for help Ando -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg_replace or chr bug?
Ok, what i wanna do is replace the codes in html with ascii equivalents: $text= ereg_replace('([0-9]+);' , chr('\1') , $text); But somehow it doesnt work, i have no idea why. When i use $text= ereg_replace('([0-9]+);' , '\1' , $text); it replaces everything correctly But $text= ereg_replace('([0-9]+);' , chr('\1') , $text); just replaces everything with an empty string using php 3.0.12 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg_replace or chr bug?
Not sure what you mean here $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text); should replace for example "A" with chr('65') (\1 means everything in brackets in regular expression), which is 'A' . Rick Emery wrote: > From the manual for chr() > > Returns a one-character string containing the character specified by ascii. > > It replaces one (1) character, not a string > > -Original Message- > From: Ando [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 28, 2002 6:59 AM > To: [EMAIL PROTECTED] > Subject: [PHP] ereg_replace or chr bug? > > Ok, what i wanna do is replace the codes in html with ascii equivalents: > > $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text); > But somehow it doesnt work, i have no idea why. > > When i use > $text= ereg_replace('&#([0-9]+);' , '\1' , $text); > it replaces everything correctly > > But > $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text); > just replaces everything with an empty string > > using php 3.0.12 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg_replace or chr bug?
Uh why do you think that? Try print chr("65"); works the same as as print chr(65); Rick Emery wrote: > chr() expects you to pass it a numeric value. You are passing it a string. > For instance, > if $text= "-", then you are trying to do: chr("45"), which is not the > same as chr(45). > Hence, ereg_replace() fails and simply returns the original string, $text. > > -Original Message- > From: Ando [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 28, 2002 7:08 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] ereg_replace or chr bug? > > Not sure what you mean here > $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text); > > should replace for example "A" with chr('65') (\1 means everything in > brackets in regular expression), which is 'A' . > > Rick Emery wrote: > > > From the manual for chr() > > > > Returns a one-character string containing the character specified by > ascii. > > > > It replaces one (1) character, not a string > > > > > -Original Message- > > From: Ando [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, March 28, 2002 6:59 AM > > To: [EMAIL PROTECTED] > > Subject: [PHP] ereg_replace or chr bug? > > > > Ok, what i wanna do is replace the codes in html with ascii equivalents: > > > > $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text); > > But somehow it doesnt work, i have no idea why. > > > > When i use > > $text= ereg_replace('&#([0-9]+);' , '\1' , $text); > > it replaces everything correctly > > > > But > > $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text); > > just replaces everything with an empty string > > > > using php 3.0.12 > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP stops execution without error message
Running php ver 3.0.12 and mysql ver 3.22.32 on a linux box. Php installed as apache module The script im running takes a long time to execute (20-40 minutes) and includes hundreds of selects and inserts into the database, and also opening/closing lots of files. And quite often, the script just stops in the middle of runnning without any error message. It isnt a timeout, since i have set_time_limit(3600); I have absolutely no idea what it can be or where to start debugging. Any ideas what it can be (ie lack of resources?) and how would it be possible to debug it. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regular expressions: HUGE speed differences
Im using a regular expression, to get all urls from a file. When using it on the webserver, it processes a 25kb html file about 0.25 seconds (PIII 350, 128mb ram, linux 2.2.13-7mdk, php 3.0.12). When i try the same on my machine (Celeron 300A, 192mb ram.), it does it about 14-17 seconds, which is about 60-70 times slower. Tested it on: redhat 7.2, php 4.1.1 - 16 seconds windows 98, php 4.1.1 - 14 seconds windows 98, php 3.0.12 - 17 seconds. The machine speed differences arent that big, especially considering that other(simpler) regexps run at the almost the same speed (20-30% difference). Where can this enourmous speed difference come from Regexp im using is following: while (eregi("(]*src[[:blank:]]*=|href[[:blank:]]*=|http-equiv=['\"]refresh['\"] *content=['\"][0-9]+;url[[:blank:]]*=|window[.]location[[:blank:]]*=|window[.]open[[:blank:]]*[(])[[:blank:]]*[\'\"]?(([[a-z]{3,5}://(([.a-zA-Z0-9-])+(:[0-9]+)*))*([:%/?=&;\\,._a-zA-Z0-9-]*))(#[.a-zA-Z0-9-]*)?[\'\" ]?",$file,$regexp)) { print $regexp[2]."\n"; $file=str_replace($regexp[0], "", $file); } Anyone care to test it on there machine? Full code (20 lines) with timing function would be: ]*src[[:blank:]]*=|href[[:blank:]]*=|http-equiv=['\"]refresh['\"] *content=['\"][0-9]+;url[[:blank:]]*=|window[.]location[[:blank:]]*=|window[.]open[[:blank:]]*[(])[[:blank:]]*[\'\"]?(([[a-z]{3,5}://(([.a-zA-Z0-9-])+(:[0-9]+)*))*([:%/?=&;\\,._a-zA-Z0-9-]*))(#[.a-zA-Z0-9-]*)?[\'\" ]?",$file,$regexp)) { print $regexp[2]."\n"; $file=str_replace($regexp[0], "", $file); } $end_time = getmicrotime()- $start_time; print "Completed in ".$end_time." seconds"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Extracting hyperlinks from file
I need to produce an array of all the links(hrefs) in a remote file (actually those that refer to files in the same remote server, but thats another matter). I'm pretty new to php, i was thinking of doing it with ereg, something like eregi("a href[\"]?=(.*)>", $file, $link); but i cannot think of a way to make it walk through the whole string, so it would find all the links, not just the first one. Any ideas? Ando -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Extracting hyperlinks from file
I need to produce an array of all the links(hrefs) in a remote file (actually those that refer to files in the same remote server, but thats another matter). I'm pretty new to php, i was thinking of doing it with ereg, somethin like eregi("a href[\"]?=(.*)>", $file, $link); but i cannot think of a way to make it walk through the whole string, so it would find all the links, not just the first one. Any ideas? Ando -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP output during longer program run times
Lets say i have a script that runs for a longer period of time, 1-10 minutes. Id like the script to give output as to what it is doing while it runs, but the problem is, that it wont print output on runtime, but it will output everything at the same time after it has completed the whole job. Even if i let it to print something out on the first line. Any workaround for this? running php 3.0.12 installed as apache module -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regular expression for (NOT 'word')
how would i build a regular expression in php that would match everything but the given word. For example, match the string only if there isnt a word 'php' in the string. I understand i can list characters i dont want to see in the string: [^php]. but this means there cant be any p or h in the string. And ^(php) checks if the string starts with 'php'. How should i do it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expression for (NOT 'word')
Ok let me explain my problem further some. I need the regular expression to purify the html page from script tags: I used: $file = eregi_replace("(.*)", " ", $file); Now this works fine, until theres a webpage like: script data. Some webpage data another script data so the regexp above replaces everything between first and last ie the webpage data also. So i thought to change the regexp to something like this: $file = eregi_replace("(NOT(script))", " ", $file); where NOT(script) would match everything that contains word script Rick Emery wrote: > the best you can do is: > > $a = "this has php in the string"; > if( ! ereg("php", $a ) ) > { print "a: not in string"; } > $a = "this has in the string"; > if( ! ereg("php", $a ) ) > { print "b: not in string"; } > ?> > > -Original Message- > From: Ando Saabas [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 14, 2002 9:33 AM > To: [EMAIL PROTECTED] > Subject: [PHP] regular expression for (NOT 'word') > > how would i build a regular expression in php that would match > everything but the given word. For example, match the string only if > there isnt a word 'php' in the string. > I understand i can list characters i dont want to see in the string: > [^php]. > but this means there cant be any p or h in the string. And ^(php) checks > if the string starts with 'php'. > How should i do it? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] rather a mysql question
Sorry that this is more of a mysql question, but since most php programmers use it a lot, i though i might find the answer without subscribing to mysql list, here goes: When i do a query from a big table using indexes,it takes for example 5 seconds. Now if i, after some time repeat the query, the query takes about 0.5 secs. So far i thought it was because of caching, but now i read mysql (v3.23) doesnt support query cache. So this really gets me wondering, where does the speed increase come from? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php