I am trying to split a text into an array using explode, but for some reason that does not work when the text is coming from a posted form.
If I run explode('|§|', 'qwe|§|asd|§|zxc');
I will get an array like:
Array
(
[0] => qwe
[1] => asd
[2] => zxc
)
BUT
If this input text comes开发者_JAVA百科 from a form define like:
<form method="post">
Input: <input type="text" name="query" size="50" value="qwe|§|asd|§|zxc"><input type="submit" value="Parse">
</form>
I am getting the following array:
Array
(
[0] => qwe|§|asd|§|zxc
)
Im guessing this has to do with iso settings and that the text in the 'query' field has been altered in some way, but I can't understand how to fix. I have tried setting <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
and other charsets, but to no avail.
Any ideas? Thanks in advance.
Just an idea: The § sign is probably be converted to url format. Try urldecode() the string first.
I'm probably mistaken on this, but §
may be a unicode character, which PHP does not yet support. Thus, there may be some issues when transferring from the form to the script.
Have you tried changing it to something more... normal? Like if you did qwe|~|asd|~|zxc
instead, or maybe qwe|+~+|asd|+~+|zxc
if you're concerned about what somebody would enter
精彩评论