如何在PHP中解析数组。 [英] How to parse an array in PHP.

查看:132
本文介绍了如何在PHP中解析数组。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手,对数组处理不太了解。我尝试了多种方法来解析下面给出的数组。但是没有得到预期的结果。我需要每个键的关键值和相关值我怎么解析这个。任何人请帮我解决这个问题。谢谢。



我的PHP代码:



$ store = array();

if(isset($ _ POST ['question_id'])){

foreach($ _POST ['question_id']为$ key => $ option){

$ store [$ key] = $ option;

}

print_r($ store);

}



?>



结果数组:



数组([2] = >数组([0] =>很多讨论;每个人都参与[1] =>团队重载了具有相同团队成员风格的人)[4] =>数组([0] => ;高度依赖)



预期结果 < br $> b $ b

2:很多讨论;每个人都参与^团队中拥有相同团队成员风格的人超载



4:高依赖性



注意:符号^用于在插入数据库之前连接这两个值。

I am new in PHP and dont know much about array handling.I tried a number of ways to parse an array which is given below.But did'nt get the expected results.I need the key and the associated values for each.How can I parse this.Any one please help me to solve this.Thanks in advance.

My PHP code:

$store = array();
if (isset($_POST['question_id'])) {
foreach ($_POST['question_id'] as $key => $option) {
$store[$key]=$option;
}
print_r($store);
}

?>

Resultant array:

Array ( [2] => Array ( [0] => A lot of discussion; everyone participates [1] => The team is overloaded with people who have the same team player style ) [4] => Array ( [0] => High dependence )

Expected Result

2:A lot of discussion; everyone participates^The team is overloaded with people who have the same team player style

4:High dependence

Note:The symbol ^ is used to join the two values before inserting in the database.

推荐答案

store = array();

if(isset(
store = array();
if (isset(


_POST ['question_id'])){

foreach(
_POST['question_id'])) {
foreach (


_POST ['question_id '] as
_POST['question_id'] as


这篇关于如何在PHP中解析数组。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆