I have a textbox user profile area where users will put rss urls separated by ‘return’ or each URLs per line. Then it will be saved to database. Now how I get all the urls in an array?
I know it is very basic question. Searched the web found lots of things and I got confused. How the I think little discussion will help.
I also want to some validation like if users don’t put any http:// before url the code will add it. And ignore URLs other then http:// protocols.
My CMS is WordPress so if there are any built in functions that might help me let me know.
After using the explode function you’ll want to do a foreach to do the validation you’re looking for
Depending on your skill level if RegEx is too complicated (though I’d really recommend learning it) you could look at using substr to evaluate each of the html lines as well, though this is a much less powerful version. An example would be:
use PHP’s explode function:
This will return an array of the URL’s assuming $POST[“URlsInputName”] contains your input box’s value that contains the URLs separated by a carriage return.
A basic block follows:
As this is user input you need to be a bit more paranoid. More error checks are always in order:
and more.