| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| DNOA Certified Seller | Looking for a program that will... I'm looking for a program that will take a bunch of randomly spaced text and place all of the words into separate lines. for example: asdf asdfasdf asdfasdfasdf. Will be cleaned into: asdf asdfasdf asdfasdfasdf Thanks!
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me |
| |
| | #2 (permalink) |
| Buy my domains. | PHP Code: |
| |
| | #3 (permalink) |
| DNOA Certified Seller | Thanks Dan. I put it here: http://www.regfee.info/php/clean.php NP won't let me rep you anymore, I must've liked something else you did ![]() How would I go about modifying this code to use a large textbox, so I could, say, edit->select all and paste random stuff into it, and each word will be put on a new line?
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me |
| |
| | #4 (permalink) | |
| NamePros Regular | Quote:
Code: <input type="text" name="stuff" style="width: 300px;" /><br /> Code: <textarea cols="40" rows="10" name="stuff"></textarea><br /> | |
| |
| | #5 (permalink) | |||
| DNOA Certified Seller | Thanks for moving it to the programming forum, mods. I didn't place it there at first because I was thinking an actual program might exist that does this, but PHP works just fine. Thanks abdussamad, I had tried this already and for some reason, it doesn't always work for huge jumbled messes of words. Here is the code, modified to clean out unnecessary characters: PHP Code: http://www.regfee.info/php/clean.php If I input Quote:
Quote:
However, if I copy and paste the entire front page of Namepros, for example, I get things like this: Quote:
Thanks again!
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me | |||
| |
| | #7 (permalink) |
| DNOA Certified Seller | Thanks Thanks manaco and everyone else. http://www.regfee.info/php/clean.php will now (hopefully) clean a big huge mess of words into words of specified length and will even tack on an extension if you'd like. Here's the code (still needs to be cleaned up, but since I'm just starting out, I like to keep everything as unoptimized as possible to minimize my own confusion.) PHP Code: Please test the script out if you get a chance and recommend any optimizations. Dan, I would like to place this tool on regfee.info, if you don't mind. Also if any of you would like me to place a link to one of your sites at the bottom of the script, just let me know. Thanks! -Jorge
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me |
| |
| | #9 (permalink) |
| NamePros Regular | Monaco's right; a regular expression match is far simpler, and can also include the min/max length checking. Here's a modification of your php code from above (I didn't copy the html below it). The code also includes a check for two additional $_POST variables: 'numbers' and 'dashes', which modify the search filter to also include numbers and/or dashes. You can add checkboxes for this (if you'd like) to your html form. PHP Code: Last edited by cef; 05-02-2007 at 05:33 PM. Reason: fixed underscore that should have been a dash |
| |
| | #10 (permalink) | |
| DNOA Certified Seller | Quote:
This is how I like to learn, by diving right into code. I try to crack open a beginner's php book, and I'm bored within 2 seconds. Your suggestion worked: PHP Code: uploaded to http://www.regfee.info/php/fasterclean.php Now I just need to display the results in a textarea for easier copy/pasting, and add a counter to display the number of generated domains. I was thinking of making it check for duplicates as well, but won't that involve either huge arrays or using a db? EDIT: Nevermind, right when I posted the question about duplicates, I realized I was being an idiot. I'm already running everything through huge arrays, so why not just use: PHP Code:
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me Last edited by RegFee; 05-02-2007 at 05:42 PM. | |
| |
| | #11 (permalink) |
| DNOA Certified Seller | Never mind, not so perfect after all. It's not removing duplicates, and since I've tried every variation of code I code find that mimics the unique array function (including one that checked if each value matched a new array and then added the value to the array if it didn't), but all of them keep failing to remove the duplicates. I have a strong feeling it is due to whitespace again, but I thought I took care of that with the ereg. Cef, I didn't even see your response! I tried it out, but it is just showing "array". I was reading up on the trim function, and it said if you try to trim an array, it will just display the word array, is this a similar problem?
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me Last edited by RegFee; 05-02-2007 at 10:20 PM. |
| |
| | #13 (permalink) |
| DNOA Certified Seller | I figured out my mistake. I was trying to remove duplicates from the miniature arrays created with each loop, but not from the final product. I ended up making it so each word that meets the length requirements is put into a new array, then that new array is finally stripped of duplicates. I then ran into the problem of different cases, and for some reason the array key case change wouldn't work, so I just did a strtolower($word) on the words before putting them in the new array. My issue NOW is getting the new dashes and numbers thing to work with ereg, since I couldn't get preg to work. PHP Code: ![]() Jorge
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me |
| |
| | #14 (permalink) |
| Buy my domains. | PHP Code: |
| |
| | #15 (permalink) |
| DNOA Certified Seller | Beautiful code, works like a charm. To whom to I make the check out to? ![]() Update: I got it to work with wordpress (frustrating). http://www.regfee.info/domain-name-generator-tool/
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me Last edited by RegFee; 05-03-2007 at 11:27 PM. |
| |
| | #16 (permalink) | |
| NamePros Regular | Quote:
Change this: PHP Code: PHP Code: | |
| |
| | #17 (permalink) | |
| DNOA Certified Seller | Quote:
Do you mind if I ask why it is necessary to add the [0] key in there? I already declared $stuff as an array, to me this seems like this would just be saying "make the first key of the array a word", not "make each key of the array a word." Thanks, Jorge
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me | |
| |
| | #19 (permalink) |
| NamePros Regular | Heh, as I was typing a response, Dan just posted! When I wrote and tested the code I used different variable names, and then refactored them into what I pasted into my response. I guess I got a little overzealous when replacing and also removed the '[0]' part, which is why it was missing here but worked when I tested it. Here's a new version, based on the last version (posted by Dan), with a couple of minor optimizations, a check and correction for min > max, and most importantly...sticky form values(!) The form now remembers and displays all setting from the last call instead of resetting everything. To do this, the code now generates the min/max size lists and extention list programmatically, so that it can easily assign the "checked" attribute to the relevant list items. Also, this makes it easier to add or remove extentions, or change the min/max sizes. Tested and works ![]() PHP Code: Last edited by cef; 05-05-2007 at 12:05 PM. |
| |
| | #20 (permalink) |
| DNOA Certified Seller | Thanks guys! Cef, my next goal was to make the form remember the settings. I didn't think to make functions to do it, definitely a lot cleaner than I would've made it. Of course, now I have to think of something else to learn how to do, thanks ![]() Your guys' help has been invaluable. Maybe in a year I'll be able to help people who are just starting out as much as you've helped me.
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me |
| |
| | #21 (permalink) | |
| NamePros Regular | Quote:
(kidding, kidding)Things to add...whois lookups for each name so that the user knows which is available for registration? Maybe some kind of alternative name suggester (a namespinner type of thing)? Just some random thoughts. Also, error checking could be a little better. Verify that min/max are in the correct bounds, verify that the extention is valid. These are a two-minute fix, but I'll leave it to you | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |