$newInfo[$stripped] = $value; ---John Holmes... > -----Original Message----- > From: Rich Hutchins [mailto:rhutchin@rochester.rr.com] > Sent: Sunday, October 13, 2002 3:42 PM > To: php-db@lists.php.net > Subject: Array Initialization > > Please forgive me ahead of time, but I didn't want to subscribe to the > high-vol general list for a single question. Actually, I need this to prep > data to be passed to a db, so it's kind of close. > > I have a variable number of hidden fields being passed from page A into > page > B via POST. On page B, I want to take those hidden fields and turn them > into > an associative array. I am able to get the data out of the $HTTP_POST_VARS > and make it look the way I want with the following code: > > <!-- BEGIN POST VARS --> > <!-- { mySelect = '40', mySelect_10 = 'Miami', mySelect_20 = 'New > England', > mySelect_30 = 'Buffalo', mySelect_40 = 'New York' } --> > > foreach ($HTTP_POST_VARS as $key => $value) { > if (preg_match("/mySelect_/", $key )) > { > echo("Found a match.<br>"); > $stripped = substr_replace($key, "", 0, 9); > echo("Content ID=".$stripped."<br>"); > echo("Its text value is: ".$value); > echo("<br><br>"); > > $newInfo = array($stripped => $value); > } > } > > print_r($newInfo); > > The resulting sample HTML data looks like this: > Found a match. > Content ID=10 > Its text value is: Miami > > Found a match. > Content ID=20 > Its text value is: New England > > Found a match. > Content ID=30 > Its text value is: Buffalo > > Found a match. > Content ID=40 > Its text value is: New York > > Array ( [40] => New York ) //here's the problem > > The problem is in the $newInfo = array($strippd => $value); and it's the > last line of the sample HTML code. > > What I want to achieve is: > Array ( [10] => Miami, [20] => New England, [30] => Buffalo, [40] => New > York ). > > Any ideas how to get there? > > Thanks in advance. > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php