Semi-Newbie question about arrays
| From: | Gremillion | Date: | Sun, 17 Aug 2003 19:45:02 +0000 |
| Subject: | Semi-Newbie question about arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159857@lists.php.net to get a copy of this message | ||
I'm trying to create a multidimensional array of values to update a Filemaker db. Edits to existing fields end in numbers (the record ID).I'm having a problem, probably obvious to anyone here in setting up the multidimensional array:
$updateEntries = array(); //stores existing db entries$ord = -1; $recNum = 0; foreach ($_POST as $key => $value) { if ($value != "") {
$lastPartPos = strrchr($key, '_');
$lastPart = substr($lastPartPos, 1);
if (preg_match("/[0-9]+/" , $lastPart)) { //if it's an existing update
$lastpartnum = strrpos($key, '_');
$firstnum = substr($key, 0, $lastpartnum);
$first = str_replace('_', '.', $firstnum); //restore periods to field name and strip off record ID at end
if ($lastPart != $recNum) {
$recNum = $lastPart;
$ord++;
$updateEntries[$ord] = $recNum;
}
$updateEntries[$ord][] = array($first, $value); //populate nested arrays of each entry
etc......
throws:
"PHP Fatal error: [] operator not supported for strings"
How do I make $updateEntries[$ord] evaluate as an array?
Thanks in advance
RG