spfoonnewb Posted January 7, 2007 Share Posted January 7, 2007 I have this code, *again*, where it takes in a bunch of fields, url1, url2, url2, url4, url5, etc.. up to 999.. anyway I want it to replace http:// & www. in the string. In the code I add http:// & www. to make sure they didn't leave it out, and I replace it to make sure there isn't two of them. It fixes many problem possibilities. My question is how would I get this to work without losing the input from each value?Here is my codes, they dont work due to .echo ["cat$l"].' but I tried other ways too. Please help :)[code]<?php$l = $_POST['i'];for ($l = 1; $l <= $_POST['l']; ++$l) $cat = str_replace("http://", "", $_POST["url$l"]);$cat = str_replace("www.", "", $_POST["url$l"]);{ echo '<option value="http://www.'.echo ["cat$l"].'">'.$_POST["name$l"].'</option>';}?>[/code] Quote Link to comment Share on other sites More sharing options...
Hypnos Posted January 7, 2007 Share Posted January 7, 2007 Is this what you're trying to do?[code]<?php$l = $_POST['i'];for ($l = 1; $l <= $_POST['l']; ++$l) {$cat = str_replace("http://", "", $_POST["url$l"]);$cat = str_replace("www.", "", $cat);echo '<option value="http://www.' . $cat . '">' . $_POST["name$l"] . '</option>';}?>[/code] Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted January 7, 2007 Author Share Posted January 7, 2007 Yep, Thanks. Quote Link to comment Share on other sites More sharing options...
alpine Posted January 7, 2007 Share Posted January 7, 2007 Just remember that not all links work with "www" but simply as "http://foo" Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted January 7, 2007 Author Share Posted January 7, 2007 Ok, thanks :)It's basically just a precaution to make sure users don't forget the http://, cause links don't work without it[code]<?php$l = $_POST['i'];for ($l = 1; $l <= $_POST['l']; ++$l) {$cat = str_replace("http://", "", $_POST["url$l"]);//$cat = str_replace("www.", "", $cat);echo '<option value="http://' . $cat . '">' . $_POST["name$l"] . '</option>';}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.