How Would I Apply htmlentities() To Every Array Item
Well, I don't know why I can't figure this out. It should have taken a few minutes for me to do but I had a lot of trouble with my broadband connection last night while I was working on it and I think that my frustration has gotten the better of me.
By the way, the likelihood of me figuring this out after I explain it here is rather high. lol
Simply put, I want to apply the function htmlentities to every item in an array even if I don't know how many items in the array or more importantly, the names of the array keys. However, the task must maintain the array key names when finished since the keys are used later to process the data.
Basically, I'm working on a generic script that would allow me to use the same script over and over for many different HTML forms. Since this script just acts as an in between script that cleans the data before it is passed to the next step, I need it to maintain all of the array information except for modifying the values as needed.
Okay, so why not just clean each item as it is processed later?
Well, the sooner I clean the data, the smaller the chance of a problem. The next step of the process is where my biggest concern is as it provides the largest security concern.
In addition to the htmlentities function, I'll be running a few more data cleaning functions on the input to ensure the safety of the system.
Fantastic! That was exactly what I needed. I wish there was a way to search the PHP site by what you want to do instead of reading through page after page of non-related information.
There is a way; if you go to the online manual, the HTML copy, and enter a function into the search box you can find it. Otherwise you're stuck browsing the manual sections to find array functions. Not a bad idea, but I know what you mean.
__________________ Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
I don't understand your question, drolex. It is possible to use them, but for what purpose? What do you want to achieve?
The default quotestyle is ENT_COMPAT which only encodes double quotes. I think I need ENT_QUOTES which will also encode single quotes. I wanted to use character set "UTF-8" because everything else is UTF-8, and the default for htmlentities is ISO-8859-1 - Western European.
I have a database that stores descriptions for things. The user often enters descriptions containing quotes. All quotes and symbols need to be converted to html entities so the description can be show and not mess up the rest of the page. I want to store the descriptions pre-encoded so it doesn't have to use extra process cycles everytime the page is shown.