![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics 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 contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Whilst lounging around on Sat, 05 Jul 2003 10:32:20 +0100, tiago borges da silva <tiago.borges-da-silva@rca.ac.uk> amazingly managed to produce the following with their Etch-A-Sketch: > Hi I'm trying to develop a php web page that allows you to type in > the name of a web site and it will pop up with a different > background color to the original one. > > I'm looking for something like: > Type in url of site ($url) > $url is read and bgcolor is found and changed (instead of yellow it > becomes white) > And window pops up with site $url having a white background. > > > I'm trying a few things such as: > > <? > $filename="http://www.panda-man.info/index.htm"; > $fd = fopen($filename,"r"); > $content=fread($fd, 300000); > fclose($fd); > $color='BGCOLOR="#FF0000/"'; > $newcolor='BGCOLOR="#FF0033/"'; > preg_replace('/$color/', $newcolor, $content); ^^^^^^^^^^^^ Waaaaaay overkill =) RegEx takes up a fair bit more processing than an alternative. I also think that the ' ' should be " " as it's looking for literally '$color' rather than the value of $color. Personally, I'd try: $content = str_replace('#FF0000', '#FF0033', $content); str_replace() is less processing intensive than RegEx functions so should be more efficient too (not that you may physically notice it here, more of a pointer in general =) ). Again, just for efficiency, no need to store the colour values in vars. > > echo($content); > > ?> > > But I'm a bit new to php and it's taking too long. > > Can any one give me a bit of help? > > Thanx very much > > Regards > > > Tiago, ze panda-man > > HTH. Regards, Ian -----BEGIN PGP SIGNATURE----- Version: PGP 8.0 iQA/AwUBPwah/mfqtj251CDhEQKwlACggqOiHaCpVz0ARIxF54F77Ca8cDsAoJ0 / JuLxCLG/RdeLgZfrXXO6raPC =ukTJ -----END PGP SIGNATURE----- -- Ian.H [Design & Development] digiServ Network - Web solutions www.digiserv.net | irc.digiserv.net | forum.digiserv.net Programming, Web design, development & hosting. | |||
|
| Advertisements |
| | #2 | ||
| Fantastic Ian! you're right, it worked. I'm using variables cos it is part of a bigger script. Is str_replace() case sensitive? I mean, would it work for BGCOLOR and bgcolor the same way? Or would I need to create a condition? Thanx tiago -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Whilst lounging around on Sat, 05 Jul 2003 10:32:20 +0100, tiago borges da silva <tiago.borges-da-silva@rca.ac.uk> amazingly managed to produce the following with their Etch-A-Sketch: > Hi I'm trying to develop a php web page that allows you to type in > the name of a web site and it will pop up with a different > background color to the original one. > > I'm looking for something like: > Type in url of site ($url) > $url is read and bgcolor is found and changed (instead of yellow it > becomes white) > And window pops up with site $url having a white background. > > > I'm trying a few things such as: > > <? > $filename="http://www.panda-man.info/index.htm"; > $fd = fopen($filename,"r"); > $content=fread($fd, 300000); > fclose($fd); > $color='BGCOLOR="#FF0000/"'; > $newcolor='BGCOLOR="#FF0033/"'; > preg_replace('/$color/', $newcolor, $content); ^^^^^^^^^^^^ Waaaaaay overkill =) RegEx takes up a fair bit more processing than an alternative. I also think that the ' ' should be " " as it's looking for literally '$color' rather than the value of $color. Personally, I'd try: $content = str_replace('#FF0000', '#FF0033', $content); str_replace() is less processing intensive than RegEx functions so should be more efficient too (not that you may physically notice it here, more of a pointer in general =) ). Again, just for efficiency, no need to store the colour values in vars. > > echo($content); > > ?> > > But I'm a bit new to php and it's taking too long. > > Can any one give me a bit of help? > > Thanx very much > > Regards > > > Tiago, ze panda-man > > HTH. Regards, Ian -----BEGIN PGP SIGNATURE----- Version: PGP 8.0 iQA/AwUBPwah/mfqtj251CDhEQKwlACggqOiHaCpVz0ARIxF54F77Ca8cDsAoJ0 / JuLxCLG/RdeLgZfrXXO6raPC =ukTJ -----END PGP SIGNATURE----- -- Ian.H [Design & Development] digiServ Network - Web solutions www.digiserv.net | irc.digiserv.net | forum.digiserv.net Programming, Web design, development & hosting. | |||
|
| | #3 | ||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Whilst lounging around on Sat, 05 Jul 2003 11:29:45 +0100, tiago borges da silva <tiago.borges-da-silva@rca.ac.uk> amazingly managed to produce the following with their Etch-A-Sketch: > Fantastic Ian! you're right, it worked. Glad it worked =) > I'm using variables cos it is part of a bigger script. Ahh, fair enough and understood. > > Is str_replace() case sensitive? Nope. > I mean, would it work for BGCOLOR and > bgcolor the same way? Nope. > Or would I need to create a condition? Nope =P str_ireplace() is what you're after for that =) http://uk.php.net/manual/en/function.str-ireplace.php Regards, Ian -----BEGIN PGP SIGNATURE----- Version: PGP 8.0 iQA/AwUBPwawN2fqtj251CDhEQKsbQCdGyktDLTRPcrSMiTgHhw1rE XrJMgAoLoT meEK4nxWSPttjWaaa50RTRS6 =n8M5 -----END PGP SIGNATURE----- -- Ian.H [Design & Development] digiServ Network - Web solutions www.digiserv.net | irc.digiserv.net | forum.digiserv.net Programming, Web design, development & hosting. | |||
|
| | #4 | ||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Whilst lounging around on Sat, 05 Jul 2003 11:02:20 GMT, "Ian.H [dS]" <ian@WINDOZEdigiserv.net> amazingly managed to produce the following with their Etch-A-Sketch: > > > > Is str_replace() case sensitive? > > > Nope. Oops, that should have been: yup =) Regards, Ian -----BEGIN PGP SIGNATURE----- Version: PGP 8.0 iQA/AwUBPwawcmfqtj251CDhEQLaYgCgm+5o78zPmstcPN9APTLTpA N5b54AoNiB gN46G0XRuPtGOt8Np9Wwnaqk =He+j -----END PGP SIGNATURE----- -- Ian.H [Design & Development] digiServ Network - Web solutions www.digiserv.net | irc.digiserv.net | forum.digiserv.net Programming, Web design, development & hosting. | |||
|
| | #5 | ||
| Thanx very much for your help Ian. Have a good day Cheerio tiago On 5/7/03 12:02, in article lubdgv4qur12nvnn2cciv5nb0mfeupigca@4ax.com, "Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Whilst lounging around on Sat, 05 Jul 2003 11:29:45 +0100, tiago > borges da silva <tiago.borges-da-silva@rca.ac.uk> amazingly managed > to produce the following with their Etch-A-Sketch: > >> Fantastic Ian! you're right, it worked. > > > Glad it worked =) > > >> I'm using variables cos it is part of a bigger script. > > > Ahh, fair enough and understood. > > >> >> Is str_replace() case sensitive? > > > Nope. > > >> I mean, would it work for BGCOLOR and >> bgcolor the same way? > > > Nope. > > >> Or would I need to create a condition? > > > Nope =P > > > str_ireplace() is what you're after for that =) > > > http://uk.php.net/manual/en/function.str-ireplace.php > > > > Regards, > > Ian > > -----BEGIN PGP SIGNATURE----- > Version: PGP 8.0 > > iQA/AwUBPwawN2fqtj251CDhEQKsbQCdGyktDLTRPcrSMiTgHhw1rE XrJMgAoLoT > meEK4nxWSPttjWaaa50RTRS6 > =n8M5 > -----END PGP SIGNATURE----- | |||
|
| | #6 | ||
| You're a star Ian!!!! I'll send you a postcard with a special thank you. Have a look at www.panda-man.info, that's me. * and regards Tiago On 5/7/03 13:19, in article r8gdgvs5675n9dgqgbuigi8nla915u0ud2@4ax.com, "Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Whilst lounging around on Sat, 05 Jul 2003 12:23:52 +0100, tiago > borges da silva <tiago.borges-da-silva@rca.ac.uk> amazingly managed > to produce the following with their Etch-A-Sketch: > >> Ian, and what about if I want to change the font. The php script >> reading the contents of a url and the body doesn't have any color >> defined in it, so body would be <body this and that but no >> bgcolor>, which would make the page to be white by default, but If >> I want to include 'bgcolor="black"' inside the <body> what would be >> the best way of doing it? With include? But what would be the best >> way to search for '<body' and include stuff straight after it? > > > The font part could be changed in a similar method: > > > $content = str_replace('font="name"', 'font="new_name"', $content); > > > If I understand the rest correctly, you could use RegEx for that: > > > if (!preg_match("#\<body.*bgcolor.*\>#i", $content)) { > // If bgcolor not found > $content = str_replace('<body ', '<body bgcolor="#FF0033" ', > $content); > } > > > This would then "insert" your bgcolor choice within the body tag if > it's not found =) > > >> >> >> <sorry to keep you busy with these questions> >> tiago > > > No probs =) > > > > HTH. > > > > Regards, > > Ian > > -----BEGIN PGP SIGNATURE----- > Version: PGP 8.0 > > iQA/AwUBPwbCYmfqtj251CDhEQL/RgCfdha65X0k9s2wcVTiP+S81//cpp0AoO60 > stexFE3RAmXNjmRtAMwEpI4k > =pt96 > -----END PGP SIGNATURE----- | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: html, interfering, php, using |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| php/html | Leandra | PHP | 3 | 07-01-2007 3:18 PM |
| embedded php in html file, how to tell calling html file? | MeNotHome | PHP | 1 | 07-01-2007 3:17 PM |
| xls to html | a.der Kinderen | HTML | 2 | 07-01-2007 1:49 PM |
| sorry for HTML | Guy Melan | Car audio | 0 | 06-17-2007 3:02 PM |
| HTML help | Stivey | HTML | 8 | 03-27-2006 3:30 AM |
| Featured Websites | ||||
|