Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 7-Oct-13 19:26pm
v3
Comments
Killzone DeathMan 18-Nov-13 5:56am    
Hello Sonya, please tell us whats the value of "$_POST['question_id']"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900