PHP数组和ヶ辆 [英] PHP array and htmlentities
本文介绍了PHP数组和ヶ辆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$_POST=
Array ( [0] => aaa@gmail.com [1] => bbb [2] => ccc [3] => ddd [4] => eee [5] => fff [6] => ggg [7] => hhh [8] => iii [9] => jjj [10] => 31 [11] => k )
foreach($_POST as $key => $val){
for ($key = 0; $key <= 9;$key++){
$_POST2[$val] = htmlentities($_POST[$val]);
}
}
}
这是我的code和我所试图做的是,我想拆分 $ _ POST
数组 $键
和 $ VAL
。然后,我想告诉大家,作为 $键
按 1
上升程序,把ヶ辆()
围绕 $ VAL
。
你能帮我么?我一直停留在这几个小时。
This is my code and what I was trying to do was that I wanted to split the $_POST
array into $key
and $val
. Then I wanted to tell the program that as the $key
goes up by 1
, put htmlentities()
around the $val
.
Can you please help me? I have been stuck on this for hours.
推荐答案
您这样做是错误的方式。试着用 -
You are doing this wrong way. Try with -
foreach($_POST as $key => $val){
$_POST2[] = htmlentities([$val]);
}
没有必要为为
循环。 的foreach
将包装所有的值。如果你想在键
s到是相同 $ _ POST
然后就让它空。
No need for that for
loop. foreach
will wrap all the values. And if you want the key
s to be same as $_POST
then just leave it empty.
这篇关于PHP数组和ヶ辆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文