PHP serialize not working
<p>I am getting input from a dynamic form (HTML+JavaScript) and extracting the data using a PHP script. I am using the <code>serialize</code> statement in PHP. This doesn't seem to be working - I am not able to get any data into the variables <code>$featureids</code> and <code>$featurenames</code> . </p>

<p>This is the code -</p>

<p>The HTML portion -</p>

<pre><code>&lt;table border = "1px" width = "700px"&gt;
    &lt;tr width&gt; &lt;td&gt;
    &lt;b&gt; Features &lt;/b&gt; &lt;br/&gt; &lt;br/&gt;
    FeatureId: &lt;input type = "text" name = "FirstFeatureId"&gt; &lt;br/&gt;
    FeatureName: &lt;input type = "text" name = "FirstFeatureName"&gt; 
    &lt;input type = "button" value = "Add Item" onclick = "addFeatureItem()" /&gt; &lt;br/&gt;
    &lt;span id = "features"&gt; &lt;br/&gt; &lt;/span&gt;
    &lt;/td&gt; &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>The JavaScript method </p>

<pre><code>function addFeatureItem(){
    //Text field to get the feature id 
    var featureIdTextField = document.createElement("input");
    featureIdTextField.setAttribute("name", "FeatureId[]");
    featureIdTextField.setAttribute("value", "Feature Id");

    var item = document.getElementById("features");
    item.appendChild(featureIdTextField);

    //Text field to get the feature name
    var featureNameTextField = document.createElement("input");
    featureNameTextField.setAttribute("name", "FeatureName[]");

    //Insert a break statement after creating a feature id and name
    var breakStatement = document.createElement("br");

    item.appendChild(featureNameTextField);
    item.appendChild(breakStatement);

}
</code></pre>

<p>and the PHP portion -</p>

<pre><code>$featureids = serialize($_POST["FeatureId"]);
echo $featureids;
$featureids = unserialize($featureids);

//inserting all the feature ids into an array
$featureIdArray = array($_POST["FirstFeatureId"]);
foreach ($featureids as $featureid) {
    echo $featureid ;
    array_push($featureIdArray, $featureid);
}

$featurenames = serialize($_POST["FeatureName"]);
$featurenames = unserialize($featurenames);

//insert all the feature names into an array
$featureNameArray = array($_POST["FirstFeatureName"]);
foreach ($featurenames as $featurename) {
    array_push($featureNameArray, $featurename);
}
</code></pre>

<p><strong>EDIT</strong> -
This is the form data in Networks->Headers in Chrome</p>

<pre><code>FirstFeatureId:fid
FirstFeatureName:fname
FeatureId[]:Feature Id
FeatureName[]:Feature Name
FeatureId[]:Feature Id
FeatureName[]:Feature Name
FeatureId:
</code></pre>

<p>Note - The very last FeatureId is empty for some reason</p>
