Extracting values from serialized form
<p>I have a page which is receiving data from a serialized form that I have no control over, the data consists of a list of values (Exam_Questions) and then a parameter for each question which is the answer to the question (Sort_Order_1). </p>

<p>There could be any number of questions which are stored in order within the parameter [exam_questions] and then a "Sort_Order_[number]" for each one of the questions. The "_[number]" relates to the order the question with within Exam_Questions i.e 101 is 1, 102 is 2 and 103 is 3. The "Sort_Order_[number]" parameter can contain different types of data and sometimes an array.</p>

<p>I have exploded the Exam_Questions into an array which has a counter, what I am trying to do is loop through the array and then request the answer values that would be submitted for the questions.</p>

<p>For example when I loop through the exam_questions on the first question I want to be able to extract Sort_Order_1 on question 2 I want to be able to extract Sort_order_2 and so on. </p>

<p>I have the "$Question_Number" value within the array but I have been unable to find a way of been able to request something like:</p>

<p>Value = $Sort_Order_ . $Question_Number</p>

<p>Here is the code I have tried so far which will extract the questions but I cant figure out how to request the "Sort_Order_[number]" values. The example below is cut down version of the string which I receive as there are other fields which are submitted.</p>

<pre><code>&lt;?php

//parse_str($_POST['Form_Values']);

parse_str('Exam_Questions=101,102,103&amp;Sort_Order_1=TEST1&amp;Sort_Order_2=TEST2&amp;  Sort_Order_3=TEST3');

$Exam_Question = (explode(",",$Exam_Questions));

$Question_Number = 1;

foreach ($Exam_Question as $QID) 
{ 

echo $Question_Number . ' - ' . $QID . '&lt;br / &gt;';

$Sort = eval('$Sort_Order_' . $Question_Number);

echo $Sort . '&lt;br /&gt;';

$Question_Number =  (int)$Question_Number + 1;
}
</code></pre>

<p>?></p>
